fix(git): propagate exit codes in push/pull/fetch/stash/worktree#234
Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom Mar 2, 2026
Merged
Conversation
run_push, run_pull, run_fetch, run_stash (pop/apply/drop/push and default), and run_worktree all printed FAILED messages on error but returned Ok(()) instead of propagating git's exit code. This breaks CI/CD pipelines and shell scripts that rely on exit code semantics (e.g. `git push || handle_error`). Fix: call std::process::exit(output.status.code().unwrap_or(1)) in each failure branch, matching the pattern already used in run_log, run_diff, run_add, and run_branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
|
Hi, Thanks for the fix! LGTM |
maxkulish
added a commit
to maxkulish/rtk
that referenced
this pull request
Mar 18, 2026
…og limits Port 5 critical bug fixes from upstream rtk-ai/rtk (v0.29.0): **P1.1a: Exit code propagation (rtk-ai#234)** - Add std::process::exit(code) to push/pull/fetch/stash/worktree/commit - Fixes CI/CD pipelines that rely on exit code semantics - Pattern: eprintln error, then exit with git's actual exit code **P1.1b: git commit -am, --amend support (rtk-ai#327/rtk-ai#360)** - Change Commit enum from {messages: Vec<String>} to unit variant - Update main.rs GitCommands::Commit to use trailing_var_arg - Update build_commit_command() to accept all args, not just -m messages - Now supports: -a, -am, --amend, --no-edit, --allow-empty, etc. - Add tests for --amend, -am flags **P1.1c: git branch creation fix (rtk-ai#194)** - Already implemented in our fork (lines 961-1019) - Detects positional args without list flags → routes to passthrough - Prevents `rtk git branch newbranch` from silently becoming a list **P1.1d: git log limit injection fix (rtk-ai#461/rtk-ai#478)** - Add parse_user_limit() to parse -N, -n N, --max-count=N/N formats - Update has_limit_flag detection to handle all limit formats - Fix: don't inject -10 when user provides their own limit - Fix: when user provides --oneline without limit, use -50 not -10 - Add 7 tests for parse_user_limit() edge cases **P1.1e: Multiple -m flags (#c18553a)** - Already supported by new trailing_var_arg implementation - Tests verify `git commit -m "title" -m "body"` works All tests pass (510 passed, 2 ignored). Zero clippy warnings. Upstream commits ported: - 5cfaecc (exit codes) - 409aed6 (commit flags) - 88dc752 (branch creation - already had) - c18553a (multiple -m - already had) - Related: rtk-ai#461, rtk-ai#478 (log limit)
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
`rtk git push`, `rtk git pull`, `rtk git fetch`, `rtk git stash` (pop/apply/drop/push/default), and `rtk git worktree` all print a `FAILED:` message on error but return exit code 0 to the caller.
This breaks CI/CD pipelines and shell scripts that rely on exit code semantics:
```bash
rtk git push || handle_error # handle_error never called
rtk git pull && deploy # deploy runs even on pull failure
```
Root cause
The failure branches in these functions print the error but fall through to `Ok(())` instead of propagating git's exit code via `std::process::exit()`.
Fix
Add `std::process::exit(output.status.code().unwrap_or(1))` in each failure branch, matching the pattern already used correctly in `run_log`, `run_diff`, `run_add`, and `run_branch`.
Per the Rust docs, `status.code()` returns `Option` — `None` when the process was killed by a signal (Unix). The `.unwrap_or(1)` fallback handles that case correctly.
Functions fixed
Testing
All 412 existing tests pass. No new behavior on the success path.
🤖 Generated with Claude Code