How to use git-parse - 1 common examples

To help you get started, we’ve selected a few git-parse 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 apollographql / apollo-tooling / packages / apollo / src / git.ts View on Github external
// Occasionally `branch` will be undefined depending on the environment, so
  // we need to fallback on `prBranch`. However in some cases, we are not able
  // to get to the branch at all. For more information, see
  const { commit, branch: ciBranch, root, prBranch } = ci();
  const gitLoc = root ? root : findGitRoot();

  if (!commit) return;

  let committer, remoteUrl, message;
  let branch = ciBranch || prBranch;

  // In order to use git-parse and git-rev-sync, we must ensure that a git context is
  // accessible. Without this check, the commands would throw
  if (gitLoc) {
    const { authorName, authorEmail, ...commit } = await gitToJs(gitLoc)
      .then((commits: Commit[]) =>
        commits && commits.length > 0
          ? commits[0]
          : { authorName: null, authorEmail: null, message: null }
      .catch(() => ({ authorEmail: null, authorName: null, message: null }));

    committer = `${authorName || ""} ${
      authorEmail ? `<${authorEmail}>` : ""

    message = commit.message;

    // The remoteUrl call can fail and throw an error
    try {


Turn a git repository into a javascript object.

Latest version published 7 months ago

Package Health Score

75 / 100
Full package analysis

Popular git-parse functions

Popular JavaScript code snippets

Find secure code to use in your application or website