Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/job/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,15 @@ func (e *Executor) updateGitMirror(ctx context.Context, repository string) (dir
e.shell.Commentf("Acquiring mirror repository update lock")
}

if isMainRepository {
// Check if the commit is in the mirror before acquiring the lock
// This is an operation that is safe to perform concurrently.
if hasGitCommit(ctx, e.shell, mirrorDir, e.Commit) {
e.shell.Commentf("Commit %q exists in mirror", e.Commit)
return e.snapshotMirror(ctx, repository, mirrorDir)
}
}

// Lock the mirror dir to prevent concurrent updates
updateCtx, canc := context.WithTimeout(ctx, lockTimeout)
defer canc()
Expand Down
Loading