Skip to content

Commit a74f044

Browse files
committed
ci(format): stage scoped file list in auto-commit step
The format job's "Commit formatting fixes" step previously fed the raw `git diff --name-only` output into `git add`. If a tracked-but-gitignored path (e.g. a build artifact) appeared in the diff, `git add` refused the ignored path and aborted the step, so the auto-fix commit never landed on the PR branch. PRs could then merge with formatting violations still present, leaving main red on the post-merge push-scope check. Stage only the paths listed in `.pr-format-files.existing.txt` — the same scoped set the formatter operates on — so unrelated diffs in the working tree can't poison the commit.
1 parent 261ce3f commit a74f044

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.github/workflows/static_quality.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ jobs:
145145
echo "No formatting changes to commit"
146146
exit 0
147147
fi
148-
git diff --name-only -z | xargs -0 git add
148+
# Stage only the files the formatter was scoped to operate on.
149+
# Piping `git diff --name-only` into `git add` is unsafe: if a
150+
# tracked-but-gitignored path shows up in the diff, `git add`
151+
# aborts the whole step and the auto-fix push never lands —
152+
# leaving formatting violations on the PR branch and (post-
153+
# merge) on main.
154+
xargs -a .pr-format-files.existing.txt git add --
149155
git commit -m "style: auto-fix formatting"
150156
git push
151157

0 commit comments

Comments
 (0)