Return failure when remote output rejects git push - #2560
Open
ahundt wants to merge 2 commits into
Open
Conversation
ahundt
force-pushed
the
v3/fix-git-push-exit-propagation
branch
from
August 2, 2026 19:29
1588886 to
151ac3c
Compare
ahundt
force-pushed
the
v3/fix-git-push-exit-propagation
branch
from
August 3, 2026 16:19
151ac3c to
f0e82ba
Compare
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
force-pushed
the
v3/fix-git-push-exit-propagation
branch
from
August 3, 2026 18:16
f0e82ba to
69aa169
Compare
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>
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.
Return failure when remote output rejects git push
Summary
rtk git pushnow 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 rejected] main -> main (push declined)with exit 0GH013: Repository rule violations foundwith exit 0pre-receive hook declinedwith exit 0Implementation
src/cmds/git/git.rsreusespush_output_indicates_rejectionin bothGitPushLineHandler::format_summaryandrun_push. The classifier covers the known remote markers[remote rejected],[rejected],GH013,push declined,pre-receive hook declined, anderror: 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
cargo clippy --all-targets --all-features -- -D warnings,cargo fmt --all -- --check, andgit diff --checkpass.