Skip to content

fix(ci): auto-format stages every tracked treefmt change (#5014) - #5304

Merged
dezren39 merged 1 commit into
mainfrom
queue/9028-5014-auto-format-companion
Nov 4, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/9028-5014-auto-format-companion

Conversation

@dezren39

@dezren39 dezren39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

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-line mod children), 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

Tests

scripts/tests/test_auto_format_workflow.py — 5/5 pass on the laptop worktree:

  • New regression test 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.
  • Harness: stub env now sets REPO_AUTOMATION_TOKEN/GH_TOKEN — all 4 pre-existing tests failed on clean main with REPO_AUTOMATION_TOKEN: unbound variable before this change; a bare origin lets the write pass really push so tests can inspect the pushed tree.
  • Two tests updated from the superseded GITHUB_TOKEN-era workflow-skip expectations to the current PAT behavior (workflow files are formatted like everything else).

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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.
@dezren39
dezren39 requested a review from a team as a code owner November 4, 2026 05:55
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 68439c86-27ac-4803-a723-6f4196cfc438
Commits

Reviewing files that changed from the base of the PR and between d53b4b2 and e5b22cb.

Files selected for processing: 2
  • .github/workflows/auto-format.yml
  • scripts/tests/test_auto_format_workflow.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T05:57:32.599743Z e5b22cb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 0dab47d into main Nov 4, 2026
1 check passed
@dezren39
dezren39 deleted the queue/9028-5014-auto-format-companion branch November 4, 2026 05:59
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.

fix(ci): auto-format stages only the listed files — treefmt companion changes (rustfmt mod children) fail the commit or are silently dropped (#3198)

1 participant