( token: string, owner: string, repo: string, branch: string, previousSHA?: string, retries = 5, delayMs = 1000 )
| 192 | |
| 193 | /** Get latest SHA with retries (useful after a merge when GitHub is still processing) */ |
| 194 | export 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 | |
| 222 | export async function createBranch( |
| 223 | token: string, |
no test coverage detected