MCPcopy Create free account
hub / github.com/SIMARSINGHRAYAT/Gitzo / getDefaultBranchSHAWithRetry

Function getDefaultBranchSHAWithRetry

src/utils/github.ts:194–220  ·  view source on GitHub ↗
(
  token: string,
  owner: string,
  repo: string,
  branch: string,
  previousSHA?: string,
  retries = 5,
  delayMs = 1000
)

Source from the content-addressed store, hash-verified

192
193/** Get latest SHA with retries (useful after a merge when GitHub is still processing) */
194export async function getDefaultBranchSHAWithRetry(
195 token: string,
196 owner: string,
197 repo: string,
198 branch: string,
199 previousSHA?: string,
200 retries = 5,
201 delayMs = 1000
202): Promise<string> {
203 for (let attempt = 0; attempt < retries; attempt++) {
204 try {
205 const sha = await getDefaultBranchSHA(token, owner, repo, branch);
206 if (previousSHA && sha === previousSHA && attempt < retries - 1) {
207 await sleep(delayMs);
208 continue;
209 }
210 return sha;
211 } catch (err) {
212 if (attempt < retries - 1) {
213 await sleep(delayMs);
214 } else {
215 throw err;
216 }
217 }
218 }
219 return await getDefaultBranchSHA(token, owner, repo, branch);
220}
221
222export async function createBranch(
223 token: string,

Callers 2

startCreatingPRsFunction · 0.90
startCreatingPairsFunction · 0.90

Calls 2

getDefaultBranchSHAFunction · 0.85
sleepFunction · 0.85

Tested by

no test coverage detected