MCPcopy Create free account
hub / github.com/angular/dev-infra / getShaForBranchLatest

Method getShaForBranchLatest

ng-dev/utils/g3.ts:105–115  ·  view source on GitHub ↗

Fetch and retrieve the latest sha for a specific branch.

(git: AuthenticatedGitClient, branch: string)

Source from the content-addressed store, hash-verified

103
104 /** Fetch and retrieve the latest sha for a specific branch. */
105 static getShaForBranchLatest(git: AuthenticatedGitClient, branch: string) {
106 // With the --exit-code flag, if no match is found an exit code of 2 is returned by the command.
107 if (git.runGraceful(['ls-remote', '--exit-code', git.getRepoGitUrl(), branch]).status === 2) {
108 Log.debug(`No '${branch}' branch exists on upstream, skipping.`);
109 return null;
110 }
111
112 // Retrieve the latest ref for the branch and return its sha.
113 git.runGraceful(['fetch', '-q', git.getRepoGitUrl(), '--', branch]);
114 return git.runGraceful(['rev-parse', 'FETCH_HEAD']).stdout.trim();
115 }
116
117 static async getG3SyncFileMatchFns(
118 git: AuthenticatedGitClient,

Callers 1

getLatestShasMethod · 0.95

Calls 2

runGracefulMethod · 0.45
getRepoGitUrlMethod · 0.45

Tested by

no test coverage detected