MCPcopy Create free account
hub / github.com/code-pushup/cli / normalizeGitRef

Function normalizeGitRef

packages/ci/src/lib/git.ts:16–37  ·  view source on GitHub ↗
(
  ref: string | GitBranch,
  git = simpleGit(),
)

Source from the content-addressed store, hash-verified

14};
15
16export async function normalizeGitRef(
17 ref: string | GitBranch,
18 git = simpleGit(),
19): Promise<GitBranch> {
20 if (typeof ref === 'object') {
21 return ref;
22 }
23 try {
24 const sha = await git.revparse(ref);
25 return { ref, sha };
26 } catch (error) {
27 if (
28 error instanceof GitError &&
29 error.message.includes(`fatal: ambiguous argument '${ref}'`)
30 ) {
31 await git.fetch(['origin', ref, '--depth=1']);
32 const sha = await git.revparse('FETCH_HEAD');
33 return { ref, sha };
34 }
35 throw error;
36 }
37}
38
39export async function listChangedFiles(
40 refs: {

Callers 1

createRunEnvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected