ci: hold the Rust files a pull request adds to rustfmt.toml #474
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!474
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-474"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@booomxd on GitHub · 2026-11-27 04:56 UTC · original
booomxd:fmt-new-files→a-publier· +34 −3 · 1 files · 1 commits · openWhy
cargo fmt --checkfails on most of the tree: 146 of the 237 Rust files, and #142 noticed it onmaintoo. Formatting everything at once would conflict with nearly every one of the 236 open pull requests. This change stops the problem from growing without touching existing code.What
fmt-new-filesjob runs on pull requests only, onubuntu-latestwith the toolchain pinned inrust-toolchain.toml. It runsrustfmt --edition 2024 --checkon the.rsfiles the PR adds, compared with the merge base of its target branch. It doesn't check files the PR edits.checkgate now also requires this job. On pushes the job is skipped, because there's no base to compare with, and the gate counts a skipped job as passed.Known limit
rustfmt follows
mod x;declarations from the files it's given. A new file that declares out-of-line modules would therefore also have those existing child files checked. That's rare, and the fix is to runrustfmton them.Testing
I ran the job's script locally against a branch that adds two formatted files, and it passed. I added a deliberately badly formatted file, and it failed, showing the diff. The YAML parses. On a fork, the job and the rest of CI passed: https://github.com/booomxd/VIctory-Belobug-AMD/pull/2
@AccelArch on GitHub · 2026-11-27 12:02 UTC · original
Read
9e49887against a-publier (4eb6cfd). I could not run the workflow or rustfmt (no Rust toolchain here), so this covers the two parts I could reproduce.The git step, run in bash (Git for Windows) in a temp repo whose PR branch adds three .rs files, edits one and renames one:
git diff --name-only --diff-filter=A "$base" HEAD -- '*.rs'lists only the added files, a path with a space survivesmapfile, the edited file and the renamed one (R100) are not listed, and a PR with no new .rs prints "This pull request adds no Rust files." and exits 0. One edge: for a new file with a non-ASCII name, git's default core.quotepath prints"src/\303\251.rs"(quoted and escaped), and that string is then passed to rustfmt as a path that does not exist.git -c core.quotepath=false diff ..., or-zwithmapfile -d '', avoids it. There are no non-ASCII .rs paths in a-publier today, so this only concerns future files.The
checkcondition, copied into Windows PowerShell 5.1 with sample results: all three existing jobs successful with fmt-new-files success or skipped passes; fmt-new-files failure or cancelled fails; a clippy failure with fmt-new-files skipped fails. The existingcheckjob hasif: always(), so a skipped fmt-new-files (pushes) does not skip the gate.--edition 2024matchesedition = "2024"in Cargo.toml, and the toolchain is the one pinned in rust-toolchain.toml.AI-assisted.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.