How to use the simple-git function in simple-git

To help you get started, we’ve selected a few simple-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / kibana / tasks / utils / files_to_commit.js View on Github external
export default function filesToCommit(path) {
  const simpleGit = new SimpleGit(path);
  const gitDiff = promisify(simpleGit.diff, simpleGit);

  return gitDiff(['--name-status', '--cached'])
    .then(output => {
      return output
        .split('\n')
        .filter(line => line.trim().length > 0) // Ignore blank lines
        .map(line => line.trim().split('\t'))
        .map(parts => {
          const status = parts[0];
          // If a file's been edited, it will only have 2 elements. If it's been renamed it will have
          // 3 elements. But in both cases, the last element is the current name of the file.
          const name = parts[parts.length - 1];
          return { status, name };
        })
        .filter(file => file.status !== 'D'); // Ignore deleted files
github elastic / kibana / utilities / visual_regression.js View on Github external
async function buildGallery(comparisons) {
  const simpleGit = new SimpleGit();
  const asyncBranch = promisify(simpleGit.branch, simpleGit);
  const branch = await asyncBranch();

  const template = Handlebars.compile(
    await readFileAsync(
      path.resolve('./utilities/templates/visual_regression_gallery.handlebars'),
      'utf8'
    ),
    { knownHelpersOnly: true }
  );

  const html = template({
    date: moment().format('MMMM Do YYYY, h:mm:ss a'),
    branch: branch.current,
    hiddenThreshold: 0,
    warningThreshold: 0.03,
github electrode-io / electrode-native / ern-core / src / gitCli.js View on Github external
export default function gitCli (workingDir?: string) {
  let simpleGitInstance = simpleGit(workingDir)
  simpleGitInstance.silent(global.ernLogLevel !== 'trace')
  return Prom.promisifyAll(simpleGitInstance)
}
github yi-ge / electron-distribution / src / routes / webhooks.js View on Github external
return new Promise((resolve, reject) => {
      git(workPath).env({
        ...process.env,
        GIT_SSH_COMMAND
      })
        .pull((err, update) => {
          if (err) {
            reject(err)
            return
          }
          if (update && update.summary.changes) {
            resolve({
              code: 1,
              type: 'pull',
              change: true
            })
          } else {
            resolve({
github elastic / kibana / x-pack / tasks / helpers / git_info.js View on Github external
export default function gitInfo() {
  const git = simpleGit(gitDir);

  return new Promise((resolve, reject) => {
    git.log((err, log) => {
      if (err) return reject(err);
      resolve({
        number: log.total,
        sha: log.latest.hash,
      });
    });
  });
}
github unfoldingWord / translationCore / src / js / helpers / GitApi.js View on Github external
function GitApi(directory) {
  var git = simpleGit(directory);

  return {
    /**
     * @description Initializes a git repository.
     * @param {function} callback - A callback to be run on complete.
     */
    init: function(callback) {
      git.init(false, callback);
    },
    /**
     * @description Pulls in from a remote branch.
     * @param {string} remote - The remote location of the git repo.
     * @param {string} branch - The branch to be pulled from, typically master.
     * @param {function} callback - A callback to be run on complete.
     */
    pull: function(remote, branch, callback) {
github nicolas-schmitt / multi-git / src / directory.js View on Github external
loadGit() {
        this.git = SimpleGit(this.path);
        this.git.silent(true);
        Promise.promisifyAll(this.git);
        this.git.runAsync = Promise.promisify(this.git._run);
    }
github mohebifar / grafgiti / src / utils / git.js View on Github external
import fs from 'fs';
import simpleGit from 'simple-git';
import { gitPath, dummyFilePath } from 'config';

const git = simpleGit(gitPath);

export function dummyCommit(day) {
  return new Promise((resolve, reject) => {
    fs.writeFile(dummyFilePath, Math.random().toString(), (err) => {
      if (err) {
        reject(err);
      } else {
        git.add(dummyFilePath, () => {
          git.commit('Dummy', dummyFilePath, {'--date': day.time.format()}, resolve);
        });
      }
    });
  });
}
github thekelvinliu / generator-espress / src / app / index.js View on Github external
this.prompt(prompts, res => {
      this.opts.projectName = slug(res.projectName);
      const dir = path.join('.', this.opts.projectName);
      if (!pathExists.sync(dir)) this.destinationRoot(dir);
      else this.env.error(`the directory '${this.opts.projectName}' already exists!`);
      this.git = simpleGit(this.destinationRoot());
      this.opts.description = res.description;
      this.opts.githubName = res.githubName;
      this.opts.buildDir = slug(res.buildDir);
      done();
    });
  }