Skip to content

Return failure when remote output rejects git push - #2560

Open
ahundt wants to merge 2 commits into
rtk-ai:developfrom
ahundt:v3/fix-git-push-exit-propagation
Open

Return failure when remote output rejects git push#2560
ahundt wants to merge 2 commits into
rtk-ai:developfrom
ahundt:v3/fix-git-push-exit-propagation

Conversation

@ahundt

@ahundt ahundt commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Return failure when remote output rejects git push

Summary

rtk git push now returns exit status 1 when remote output reports a rejection even if the child process exits 0. RTK retains the server diagnostic and does not print a successful ref summary for the rejected push.

Before and after

Remote output Before After
[remote rejected] main -> main (push declined) with exit 0 RTK could print a success summary and return 0. RTK retains the diagnostic and returns 1.
GH013: Repository rule violations found with exit 0 A server-side ruleset failure could be hidden by the zero process status. RTK classifies the push as failed.
pre-receive hook declined with exit 0 The rejection could be treated as ordinary progress. RTK returns failure and retains the message.
Ordinary progress with no rejection marker A broad check could misclassify a successful push. The existing success summary remains unchanged.

Implementation

src/cmds/git/git.rs reuses push_output_indicates_rejection in both GitPushLineHandler::format_summary and run_push. The classifier covers the known remote markers [remote rejected], [rejected], GH013, push declined, pre-receive hook declined, and error: failed to push, with case-insensitive matching where server capitalization varies.

Scope and limitation

This corrects known server and ruleset messages without changing unrelated Git commands. Git normally returns a non-zero status for rejection; a new server wording that contains none of the known markers still depends on the underlying process status and should receive a focused regression case when observed.

Verification

  • Focused tests cover zero-exit rejection output, server variants, capitalization, retained diagnostics, and non-rejection progress.
  • The full branch suite passes with 2,564 tests passed and 8 ignored.
  • cargo clippy --all-targets --all-features -- -D warnings, cargo fmt --all -- --check, and git diff --check pass.

@CLAassistant

CLAassistant commented Jun 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ahundt
ahundt force-pushed the v3/fix-git-push-exit-propagation branch from 1588886 to 151ac3c Compare August 2, 2026 19:29
@ahundt ahundt changed the title Fail git push when remote output reports rejection Return failure when remote output rejects git push Aug 2, 2026
@ahundt
ahundt force-pushed the v3/fix-git-push-exit-propagation branch from 151ac3c to f0e82ba Compare August 3, 2026 16:19
Treat remote rejection text as a failed `git push` even when the child exits with status 0. GitHub rulesets and server-side hooks can emit `[remote rejected]`, `GH013`, `pre-receive hook declined`, or `error: failed to push` without a reliable nonzero process status.

Reuse `push_output_indicates_rejection` for both `GitPushLineHandler::format_summary` and `run_push`, so RTK does not print `ok <ref>` and returns exit code 1 while retaining the diagnostic output.

Files: `src/cmds/git/git.rs`; tests cover zero-exit rejection output, server variants, case differences, and non-rejection progress.
Verification: `cargo test -q` with isolated HOME (2513 passed, 8 ignored in the main binary; all auxiliary suites passed), focused push tests (9 passed), `cargo check -q`, `cargo fmt -- --check`, and `git diff --check`.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
@ahundt
ahundt force-pushed the v3/fix-git-push-exit-propagation branch from f0e82ba to 69aa169 Compare August 3, 2026 18:16
Why: The pull request must be current with develop while preserving nonzero status for remote rejection text.

What: Merge current upstream/develop into v4/fix-git-push-exit-propagation. The merge is conflict-free and retains upstream Git command changes.

Verification: merge-base scope and merge-tree conflict check completed before merge; full gates follow on the merged head.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
ahundt added a commit to ahundt/rtk that referenced this pull request Aug 24, 2026
Why:
The combined integration proof must include PR rtk-ai#2560 server-side rejection propagation with the current Git runner.

What:
Merge v4/fix-git-push-exit-propagation so zero-exit push rejection markers still return failure while retaining streamed commit behavior and diagnostics.

Verification:
- git diff --cached --check
- inspected staged src/cmds/git/git.rs union before commit

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
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.

2 participants