Skip to content

Commit 2424439

Browse files
Short-circuit run resolution on default branch
- Move the default branch check before ResolveLatestRun call - When on the default branch, use repo-level data directly instead of waiting for run resolution to fail first - Avoids unnecessary API call and error handling path
1 parent eca147f commit 2424439

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

command/cmdutil/resolve_run.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,14 @@ func resolveWithoutPR(
307307
remote *vcs.RemoteData,
308308
result *AutoBranchResult,
309309
) (*AutoBranchResult, error) {
310+
// If on the default branch, use repo-level data directly.
311+
if branchName != "" && branchName == GetDefaultBranch() {
312+
result.UseRepo = true
313+
return result, nil
314+
}
315+
310316
commitOid, _, runStatus, resolveErr := ResolveLatestRun(ctx, client, branchNameFunc, remote)
311317
if resolveErr != nil {
312-
if branchName != "" && branchName == GetDefaultBranch() {
313-
result.UseRepo = true
314-
return result, nil
315-
}
316318
return nil, resolveErr
317319
}
318320

0 commit comments

Comments
 (0)