Skip to content

refactor(git): unify state-push rebase-retry into one dir-aware helper - #463

Merged
joshua-temple merged 1 commit into
mainfrom
refactor/unify-state-push-retry
Jul 5, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
refactor/unify-state-push-retry

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

internal/orchestrate/orchestrator.go carried its own push / git pull --rebase / git 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 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:

  • Add WithDir and WithBackoff options plus a single shared retry loop in internal/git/git.go.
  • Expose PushWithRebaseRetry as the push half for callers that stage and commit through their own flow.
  • Rewrite orchestrator.pushStateWithRetry to delegate to git.PushWithRebaseRetry(git.WithDir(o.baseDir), git.WithBackoff(o.pushBackoff)), removing the duplicated loop.

The existing positional CommitAndPushWithRetry callers (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=1 green (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.
  • New git-package tests cover the exported push helper with the dir and backoff options for both the retry-success and conflict-abort paths.

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>
@joshua-temple
joshua-temple merged commit abf0f35 into main Jul 5, 2026
19 checks passed
@joshua-temple
joshua-temple deleted the refactor/unify-state-push-retry branch July 5, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant