How to use the isomorphic-git.resolveRef function in isomorphic-git

To help you get started, weโ€™ve selected a few isomorphic-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 / x-pack / legacy / plugins / code / server / git_operations.ts View on Github external
oid = await isogit.expandOid({ gitdir, oid });
        }
        obj = await isogit.readObject({ gitdir, oid, format: 'parsed' });
      } catch (e) {
        // expandOid or readObject failed
      }
    }
    // test if it is a reference
    if (!obj) {
      try {
        // try local branches or tags
        oid = await isogit.resolveRef({ gitdir, ref, depth: 10 });
      } catch (e) {
        // try remote branches
        try {
          oid = await isogit.resolveRef({ gitdir, ref: `origin/${ref}`, depth: 10 });
        } catch (e1) {
          // no match
        }
      }
      if (oid) {
        obj = await isogit.readObject({ gitdir, oid, format: 'parsed' });
      }
    }
    if (obj) {
      if (obj.type === 'commit') {
        const commit = obj.object as isogit.CommitDescription;
        return {
          id: obj.oid,
          author: commit.author.name,
          committer: commit.committer.name,
          message: commit.message,
github CleverCloud / clever-tools / src / models / git.js View on Github external
async function getBranchCommit (refspec) {
  const repo = await getRepo();
  return git.resolveRef({ ...repo, ref: refspec });
}
github casual-simulation / aux / WebClient / GitManager.ts View on Github external
async resolveRef(ref: string): Promise {
        try {
            const commitSha = await resolveRef({
                dir: this.projectDir,
                ref: ref
            });

            return commitSha;
        } catch(err) {
            return null;
        }
    }
github elastic / kibana / x-pack / legacy / plugins / code / server / git_operations.ts View on Github external
public async getDefaultBranch(uri: RepositoryUri): Promise {
    const gitdir = this.repoDir(uri);
    const ref = await isogit.resolveRef({ gitdir, ref: HEAD, depth: 2 });
    if (ref.startsWith(REFS_HEADS)) {
      return ref.substr(REFS_HEADS.length);
    }
    return ref;
  }
github adobe / helix-cli / src / git-utils.js View on Github external
static async getCurrentRevision(dir) {
    return git.resolveRef({ dir, ref: 'HEAD' });
  }
github nteract / nteract / applications / desktop / src / notebook / epics / git.js View on Github external
dir: filepath.substring(0, filepath.lastIndexOf("/"))
      };
      if (
        !fs.existsSync(
          filepath.substring(0, filepath.lastIndexOf("/")) + "/.git/"
        )
      ) {
        return of(
          actions.gitListBranchFailed({
            error: new Error("no notebook loaded to list currentBranch"),
            contentRef: action.payload.contentRef
          })
        );
      }

      return from(git.resolveRef({ ...repo, ref: "HEAD", depth: 1 })).pipe(
        map(currentBranch =>
          actions.gitListBranchSuccessful({
            currentBranch: currentBranch.substring(
              currentBranch.lastIndexOf("/") + 1,
              currentBranch.length
            )
          })
        ),
        catchError(err => actions.gitListBranchFailed(err))
      );
    })
  );
github elastic / kibana / x-pack / legacy / plugins / code / server / git_operations.ts View on Github external
public async getHeadRevision(uri: RepositoryUri): Promise {
    const gitdir = this.repoDir(uri);
    return await isogit.resolveRef({ gitdir, ref: HEAD, depth: 10 });
  }