You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
prose_lint.py Treats an Empty --diff as No Diff and Widens a Scoped Run to the Whole Tree #1537
prose_lint.py treats an empty --diff value as though no --diff was given, so the run widens to the whole tree and reports the existing backlog as though the change introduced it. That is the exact outcome the refusal right below it exists to prevent.
.github/actions/prose-gate/prose_lint.py at main (fb42028), line 1849:
scope=changed_lines(a.diff, scan_root) ifa.diffelseNoneifa.diffandscopeisNone:
# Widening to the whole tree answers a different question, and answers it silently.
An empty string is falsy, so scope is None and the if a.diff and scope is None refusal never fires.
Reach
The composite action is not affected, since it verifies $BASE resolves before calling the script. The exposed path is a local run, where a caller computes the base in a command substitution, for example --diff "$(git merge-base origin/develop HEAD)". When origin/develop does not exist, as in a single-branch clone of main, git merge-base prints only a fatal: line to stderr and the script receives --diff "".
It fails loudly rather than giving a false clean, but the findings it prints belong to the whole tree, with nothing saying the scope was lost.
Reproduction
A synthetic repository with one committed line carrying a semicolon and one untracked clean file:
git init -q r &&cd r
git commit -q --allow-empty -m base
printf'Old text; with a semicolon.\n'> a.md && git add a.md && git commit -q -m add
printf'New clean line.\n'> b.md
python3 <hub>/.github/actions/prose-gate/prose_lint.py --diff HEAD -- .# exit 0, 1 changed line
python3 <hub>/.github/actions/prose-gate/prose_lint.py --diff "" -- .# exit 1, a.md:1 semicolon
python3 <hub>/.github/actions/prose-gate/prose_lint.py --diff no-such-ref -- .# exit 2, the intended refusal
The empty-value run reports a.md:1: semicolon, a line the change never touched, where an unresolvable ref gets the intended refusal.
Suggested fix
Test for presence rather than truthiness, if a.diff is not None, so an empty value reaches changed_lines, fails to resolve, and takes the existing refusal. Rejecting an empty --diff at argument parsing would do the same.
Found while documenting the local prose-gate invocation in ptr727/aiopurpleair.
Activity
Read an Empty prose_lint --diff as a Failed Base, Not as No Diff (#1566)
Promote develop to main: Read an Empty prose_lint --diff as a Failed …