Skip to content

refactor(git): share one branch push for the fast-forward and force cases - #1286

Merged
BryanFRD merged 1 commit into
mainfrom
refactor/push-branch-once
Oct 6, 2026
Merged

BryanFRD merged 1 commit into
mainfrom
refactor/push-branch-once

Conversation

@BryanFRD

@BryanFRD BryanFRD commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Closes #1284

try_push_branch_once and try_force_push_branch_once were the same 25 lines, the duplicated block Sonar reports in src/git/push.rs. They now share push_branch_once, driven by a BranchPush mode (FastForward, Force) that supplies the + refspec prefix, the verb, the spawned command for the context and the error code (E2004 / E2012).

No behaviour change: the refspecs, retry labels, messages and codes are the same as before, and force_push_branch keeps its refname validation. Covered by the existing push and release-PR tests.

@BryanFRD
BryanFRD enabled auto-merge (squash) October 6, 2026 06:49

@ferrfleet ferrfleet Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactor doesn't change behaviour. For both modes, the refspec (+ only for force), the retry label, the spawn and failure messages, and the error codes (GIT_PUSH_BRANCH / GIT_FORCE_PUSH_BRANCH) all match the two removed functions. force_push_branch still validates refnames before pushing, and nothing else referenced try_push_branch or try_force_push_branch_once. is_push_rejected_error and is_transient_git_error read message text, and the text they see is unchanged, so retry and regenerate classification stays the same. No findings.

@BryanFRD
BryanFRD merged commit 5b91811 into main Oct 6, 2026
32 checks passed
@BryanFRD
BryanFRD deleted the refactor/push-branch-once branch October 6, 2026 06:51
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.

refactor(git): push_branch and force_push_branch duplicate their whole body

1 participant