How to use the simple-git/promise 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 decaffeinate / bulk-decaffeinate / src / convert.js View on Github external
async function assertGitWorktreeClean() {
  let status = await git().status();
  if (status.files.length > status.not_added.length) {
    throw new CLIError(`\
You have modifications to your git worktree.
Please revert or commit them before running convert.`);
  } else if (status.not_added.length > 0) {
    console.log(`\
Warning: the following untracked files are present in your repository:
${status.not_added.join('\n')}
Proceeding anyway.
`);
  }
}
github lifegadget / generator-typescript-microservice / src / closure.ts View on Github external
export async function closure(context: IGeneratorDictionary) {
  const git = simplegit(context.destinationPath());
  try {
    const checkIsRepo = await git.checkIsRepo();

    if (checkIsRepo) {
      console.log(
        chalk`{grey - This project is already setup as a git repo; doing nothing more}`
      );
    } else {
      console.log(
        chalk`{grey - this project has {italic not yet} been setup as a git repository}`
      );

      await git.init();
      console.log(
        chalk`- This project has been registered as a {bold git} project`
      );
github decaffeinate / bulk-decaffeinate / src / land.js View on Github external
message += `\n\n${differentialRevisionLine}`;
        await git().commit(message, ['--amend']);
      }
    }
  }

  console.log(`Creating merge commit on ${remoteBranch}`);
  let cherryPickHeadCommit = (await git().revparse(['HEAD'])).trim();
  await git().checkout(remoteBranch);

  let mergeMessage = `Merge decaffeinate changes into ${remoteBranch}`;
  if (phabricatorAware) {
    mergeMessage += `\n\n${differentialRevisionLine}`;
  }
  await git().mergeFromTo(cherryPickHeadCommit, 'HEAD', ['--no-ff']);
  await git().commit(mergeMessage, ['--amend']);
  if (phabricatorAware) {
    console.log('Pulling commit message from Phabricator.');
    await exec('arc amend');
  }
  console.log('');
  console.log('Done. Please verify that the git history looks right.');
  console.log('You can push your changes with a command like this:');
  console.log(`git push ${remote} HEAD:${upstreamBranch}`);
  console.log('If you get a conflict, you should re-run "bulk-decaffeinate land".');
}
github grommet / grommet-site / tools / release-heroku.js View on Github external
del(localFolder).then(() => {
    git()
      .silent(true)
      .clone(repoURL, localFolder)
      .then(() => git(localFolder).checkout('heroku'))
      .then(() => del([`${localFolder}/**/*`]))
      .then(() => fs.copy(localDist, localFolder))
      .then(() => git(localFolder).add(['--all', '.']))
      .then(() => git(localFolder).commit('heroku updated'))
      .then(() => git(localFolder).push('origin', 'heroku'))
      .catch(err => console.error('failed: ', err));
  });
} else {
github grommet / grommet / tools / release-stable.js View on Github external
del(localFolder).then(() => {
    git()
      .silent(false)
      .clone(repoURL, localFolder)
      .then(() => git(localFolder).checkout('stable'))
      .then(() => del([`${localFolder}/**/*`]))
      .then(() => fs.copy(localDist, localFolder))
      .then(() => git(localFolder).add(['--all', '.']))
      .then(() => git(localFolder).commit('stable updated'))
      .then(() => git(localFolder).push('origin', 'stable'))
      .catch(err => console.error('failed: ', err));
  });
} else {
github Val-istar-Guo / mili / src / class / repository / local-repository.ts View on Github external
public async getVersions(): Promise {
    const { path } = this
    if (this.versions) return this.versions
    if (!(await git(path).checkIsRepo()) || !await isRootDirOfRepo(path)) {
      this.versions = []
      return this.versions
    }

    const tags = await git(path).tags()

    if (!tags.all.length) {
      logger.warn([
        'Cannot get template versions, May be caused by the following reasons:',
        `1. repository is not a mili template(${path})`,
        '2. template have not a valid tag to mark the version(e.g. v1.0.0)',
        `3. cannot get versions by command: \`git tags ${path}\``,
      ].join('\n'))
    }

    this.versions = tags.all
github grommet / grommet-site / tools / release-heroku.js View on Github external
      .then(() => git(localFolder).add(['--all', '.']))
      .then(() => git(localFolder).commit('heroku updated'))
github Val-istar-Guo / mili / src / class / repository / git-repository.ts View on Github external
public async existed(): Promise {
    try {
      const result = await git().listRemote([])
      return Boolean(result && result.length)
    } catch (e) {
      return false
    }
  }
}