Fetch and retrieve the latest sha for a specific branch.
(git: AuthenticatedGitClient, branch: string)
| 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, |
no test coverage detected