Repository navigation
fix(ci): exempt SDK-written lock files from the newline hook - #40
Merged
Merged
Conversation
end-of-file-fixer and the .NET SDK disagree about two files, and the SDK wins. `dotnet restore` writes packages.lock.json with the closing brace as its last byte, and `dotnet tool` does the same to .config/dotnet-tools.json. A human never sees it, because the hook appends the newline before the file reaches a commit. Dependabot's updater does not run pre-commit, so its regenerated lock files reach CI raw, and `make ci` fails on a file nobody wrote. That happens on every NuGet bump. Exclude the two files by name, so a hand-written JSON file missing its final newline is still caught.
`baseline-drift` compares this repository's shared pre-commit definitions
with the reviewed git-template checkout, so excluding the SDK-written
lock files from end-of-file-fixer reports:
pre-commit configuration differs: https://github.com/pre-commit/pre-commit-hooks
The exclude cannot move upstream. git-template is language neutral and
has no packages.lock.json or .config/dotnet-tools.json, so the hook and
the SDK only disagree here. Record it as a deliberate difference, which
is what .github/git-baseline-exceptions.json is for.
Verified against the pinned baseline 3908f46 in both repositories: the
check reports the accepted difference and exits 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every Dependabot NuGet bump fails
make cion the same hook:#36 and #37 are both stuck on it right now, and so are four PRs in a repo generated from this template.
The .NET SDK writes
packages.lock.jsonand.config/dotnet-tools.jsonwithout a final newline. Our own commits look clean becauseend-of-file-fixerappends one before the file reaches a commit, so the committed files end0awhile anything the SDK regenerates ends7d. Dependabot's updater never runs pre-commit, so its lock files arrive raw, the hook rewrites them in CI, and the run fails.This excludes those two paths from that one hook. Dependabot cannot be taught to run pre-commit, and
.gitattributesis no help either: text normalisation rewrites CRLF, it cannot add a missing final newline.Checked against a worktree of
origin/dependabot/nuget/dot-config/routine-a79334c9c9, where all three generated files are missing the newline:end-of-file-fixerpasses and leaves those files byte-identicalmake cipasses on this branchScoped by filename rather than by extension, so ordinary JSON keeps the rule.
baseline-driftthen reported the change, because it compares our shared pre-commit definitions against the reviewedgit-templatecheckout:The exclude cannot move upstream.
git-templateis language neutral and has nopackages.lock.jsonor.config/dotnet-tools.json, so the hook and the SDK only disagree here. The second commit records it in.github/git-baseline-exceptions.json, the waydocs/security-baseline.mdprescribes. Checked against the pinned baseline3908f46: the check prints the accepted difference and exits 0.