Skip to content

prose_lint.py Reads the Diff Prefix From Host Config, So Four Ordinary Settings Empty the Scope #1575

Description

@ptr727

Problem

changed_lines in .github/actions/prose-gate/prose_lint.py keys diff scope off a +++ header it expects to begin b/. That prefix is not a property of git's output, it is a default the host's configuration can change, and the gate reads whichever the host has rather than pinning its own.

Four ordinary settings each empty the scope:

Setting What the header becomes
diff.noprefix=true +++ file.md, no prefix at all
diff.mnemonicPrefix=true +++ w/file.md, the prefix varying by source
diff.dstPrefix=y/ +++ y/file.md
diff.external=<command> no diff body at all

An empty scope is falsy, so the if scope and not matched refusal in main never fires. The run prints scope: 0 of N file(s) read and exits 0.

Evidence

Constructed: a repository holding one file with a duplicated word, one changed line.

settings unset          exit 1, the violation reported
diff.mnemonicPrefix     scope: 0 of 1 file(s) read, exit 0
diff.noprefix           scope: 0 of 1 file(s) read, exit 0
diff.dstPrefix=y/       scope: 0 of 1 file(s) read, exit 0
diff.external=<cmd>     scope: 0 of 1 file(s) read, exit 0

Confirmed present at a3cd9c7, so this is not a regression from #1574.

Reach

diff.mnemonicPrefix is an ordinary developer setting, so a maintainer carrying it gets a clean verdict from every local pre-push run of the gate. A CI runner carries none of them, so CI is unaffected and nothing here would notice.

Suggested fix

Pin what the parse depends on rather than inheriting it, the way #1574 pinned core.quotePath for the same reason in the same function: --no-ext-diff --src-prefix=a/ --dst-prefix=b/ on the same invocation. Verified to restore +++ b/ under all four settings.

TestDiffScopeReachesAQuotedName pins core.quotePath in its fixture and should pin these alongside it, since its own stated rationale covers them.

Found by a local review pass while fixing #1538 in #1574.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions