Skip to content

feat: add git checkout support#2859

Merged
aeppling merged 1 commit into
rtk-ai:developfrom
kenwoodjw:feature/git-checkout-support
Jul 8, 2026
Merged

feat: add git checkout support#2859
aeppling merged 1 commit into
rtk-ai:developfrom
kenwoodjw:feature/git-checkout-support

Conversation

@kenwoodjw

Copy link
Copy Markdown
Contributor

Summary

Closed #1728

  • Add compact rtk git checkout support for branch switching, new/reset branch checkout, and path restore forms.
  • Enable hook rewrite coverage for git checkout ....
  • Preserve checkout exit codes while surfacing concise ok ... success output and focused failure messages.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected
  cargo build

  tmp=$(mktemp -d)
  cd "$tmp"
  git init -q -b main
  git config user.email t@t.t
  git config user.name t
  git commit -q --allow-empty -m init

  /path/to/rtk/target/debug/rtk git checkout -b feature/test
  # expect: ok feature/test (new)

  /path/to/rtk/target/debug/rtk git checkout main
  # expect: ok main

  check path restore:

  printf 'original\n' > a.txt
  printf 'original\n' > b.txt
  git add a.txt b.txt
  git commit -q -m 'add files'

  printf 'changed\n' > a.txt
  printf 'changed\n' > b.txt

  /path/to/rtk/target/debug/rtk git checkout HEAD -- a.txt b.txt
  # expect: ok 2 files restored

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

@CLAassistant

CLAassistant commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@aeppling

aeppling commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Hey @kenwoodjw

Thanks for this addition,
Here is some things to be addressed before merge.

Use the shared runner

run_checkout hand-rolls exec_capture + manual print/track like the legacy run_add/run_fetch. It fits runner::run_filtered_with_exit + RunOptions::with_tee(...) (output is a pure function of args, raw, exit).
That gives the never_worse guard, tee reversibility, and central tracking for free.

Failure filter drops the filenames

On a dirty tree, it keeps the error: header and Aborting but discards the indented file list, leaving "the following files" with no files.

@aeppling aeppling self-assigned this Jul 7, 2026
@kenwoodjw kenwoodjw force-pushed the feature/git-checkout-support branch from 9c29875 to 0edcaab Compare July 7, 2026 13:36
@aeppling

aeppling commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@kenwoodjw got a failing test :p

@kenwoodjw kenwoodjw force-pushed the feature/git-checkout-support branch from 0edcaab to bb01d6c Compare July 8, 2026 03:12
@kenwoodjw

Copy link
Copy Markdown
Contributor Author

@kenwoodjw got a failing test :p

fixed, Please try again. Thanks.

@aeppling

aeppling commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Hey @kenwoodjw

LGTM, thanks for contributing to RTK by adding more coverage :)

@aeppling aeppling merged commit be1844c into rtk-ai:develop Jul 8, 2026
11 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 8, 2026
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.

Add rtk git checkout support

3 participants