refactor(git): unify state-push rebase-retry into one dir-aware helper - #463
Merged
Merged
Conversation
The orchestrator carried its own push/pull --rebase/rebase --abort retry loop that duplicated git.CommitAndPushWithRetry. The copy existed only because the orchestrator runs git against its base directory (cmd.Dir) while the package helper ran in the process working directory, and because its test needed a fast backoff. Add functional options (WithDir, WithBackoff) to the git helpers and extract the retry loop into a single shared implementation. Expose PushWithRebaseRetry as the push half for callers that stage and commit through their own flow. The orchestrator now delegates to it with its base directory and backoff, so the rebase-abort-on-conflict behaviour lives in exactly one place. Existing CommitAndPushWithRetry callers are unchanged: the options tail is additive with no-op defaults. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
internal/orchestrate/orchestrator.gocarried its own push /git pull --rebase/git rebase --abortretry loop that duplicatedgit.CommitAndPushWithRetry. The copy existed only because the orchestrator runs git against its base directory (cmd.Dir) while the package helper ran in the process working directory, and because its test needed a fast retry backoff. Keeping two copies meant the rebase-abort-on-conflict fix had to be applied and maintained twice.Fix
Make the shared git helper directory-aware and backoff-injectable through cascade's functional-options convention, then reuse it from the orchestrator so there is a single rebase-retry implementation:
WithDirandWithBackoffoptions plus a single shared retry loop ininternal/git/git.go.PushWithRebaseRetryas the push half for callers that stage and commit through their own flow.orchestrator.pushStateWithRetryto delegate togit.PushWithRebaseRetry(git.WithDir(o.baseDir), git.WithBackoff(o.pushBackoff)), removing the duplicated loop.The existing positional
CommitAndPushWithRetrycallers (promote and hotfix finalize) are unchanged: the options tail is additive with no-op defaults. The rebase-abort-on-conflict behaviour now lives in exactly one place.Verification
go build ./...clean.go test ./... -race -count=1green (2345 passed across 33 packages), including the orchestrator non-fast-forward and rebase-conflict-abort regression tests and the git helper conflict test, all still load-bearing.golangci-lint run ./...clean.