Repository navigation
ci(lint): require an SPDX license header in Rust files - #132
Merged
Merged
Conversation
stewartadam
force-pushed
the
ci/spdx-license-headers
branch
from
November 29, 2026 06:42
0e57e6a to
24b954f
Compare
stewartadam
enabled auto-merge (squash)
November 29, 2026 06:43
stewartadam
force-pushed
the
ci/spdx-license-headers
branch
2 times, most recently
from
November 29, 2026 06:53
dfc46a5 to
850e3d7
Compare
Add the insert-license prek hook, which checks that every Rust file starts with `// SPDX-License-Identifier: MIT OR Apache-2.0` and adds the line where it is missing. CI's lint job now runs it whenever a Rust file or the header config changes. Add the header to the existing Rust files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SPDX identifier on line 1 now states each file's license, so remove the repeated copyright and license prose. The notes on each file's origin stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stewartadam
force-pushed
the
ci/spdx-license-headers
branch
from
November 29, 2026 06:56
850e3d7 to
699a846
Compare
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.
What
insert-license(MIT licensed), that checks every Rust file starts with// SPDX-License-Identifier: MIT OR Apache-2.0, matchinglicense = "MIT OR Apache-2.0"inCargo.toml. The header text lives in.license-header.txt. When a file is missing it, the hook adds the line and fails so the change can be reviewed and staged.--detect-license-in-X-top-lines=1). The hook normally skips leading#!lines as shebangs, which would put the header below a file's inner attributes (such aswarn(missing_docs)).--insert-license-after-regex=(?!)(a regex that never matches) makes it insert at the very top.lintjob now also runsinsert-license, and a newheaderspath filter (**/*.rs,.license-header.txt,.pre-commit-config.yaml) triggers it. No newuses:lines, soactions.lockis unchanged.further testing/, and removed the long-formCopyright 2020 sacn Developers/Licensed under the Apache License...blocks it replaces. Each file's note on its origin (the St Andrews dissertation project) is kept.Testing
prek run insert-license --all-filespasses on this branch.-D warnings), rumdl and actionlint all pass.Shell scripts and other non-Rust files are out of scope here. They could get a
#-style header from a second hook entry if wanted.Generated by Claude Code