Repository navigation
fix(ci): auto-format stages every tracked treefmt change (#5014) - #5304
Merged
Merged
Conversation
The write pass staged only the files listed for treefmt, while its no-change decision used the whole worktree. rustfmt companion changes (out-of-line mod children of a listed parent) were therefore silently dropped or failed the commit with "no changes added to commit", wedging later runs for the range. Stage all tracked changes (git add -u) after treefmt runs and decide nothing-to-commit from the staged diff. The checkout is clean before treefmt, so every tracked modification is treefmt's. Tests: the harness gains REPO_AUTOMATION_TOKEN/GH_TOKEN stub env (all 4 pre-existing tests failed on clean main with unbound REPO_AUTOMATION_TOKEN), a bare origin so the write pass can really push, formatter side-effect simulation, and two tests updated from the superseded GITHUB_TOKEN workflow-skip behavior to the PAT arrangement (#3118). New regression test covers the companion case end to end: listed file already formatted, formatter rewrites an unlisted tracked file, run exits 0 and the companion change is in the pushed commit.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
4 tasks
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.
Fixes #5014 (task 9028, repo-health-code-pilot).
Problem
The auto-format write pass ran treefmt on the listed files, decided "changed?" from the whole worktree (
git diff --quiet), then staged only the listed files and committed unconditionally. treefmt/rustfmt rewrites companions of listed files (out-of-linemodchildren), so a companion-only change either failed the commit with "no changes added to commit" (wedging every later run for the range) or was silently dropped.Fix
git add -uafter the format run (the checkout is clean before treefmt, so every tracked modification is treefmt's).git diff --cached --quiet).Tests
scripts/tests/test_auto_format_workflow.py— 5/5 pass on the laptop worktree:test_companion_change_is_committed_and_pushed: executes the workflow's real run block; listed file already formatted, the (stubbed) formatter rewrites an unlisted tracked companion; asserts exit 0 and the companion change is in the pushed commit. It fails (rc=1) against the unmodified workflow.REPO_AUTOMATION_TOKEN/GH_TOKEN— all 4 pre-existing tests failed on clean main withREPO_AUTOMATION_TOKEN: unbound variablebefore this change; a bareoriginlets the write pass really push so tests can inspect the pushed tree.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.