-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SPDX headers #1532
base: main
Are you sure you want to change the base?
Add SPDX headers #1532
Conversation
f3fbba4
to
0740712
Compare
This will be used to verify that source files (just *.rs for now) all have an SPDX license header. In non-check mode, the license header will be added. For now, in check mode an error is shown but it's not treated as fatal. Once all files have been fixed, the error will be made fatal.
0740712
to
8cdf08d
Compare
let paths = std::str::from_utf8(&output.stdout)?.lines(); | ||
|
||
// Path prefixes that should not be checked/formatted. | ||
let exclude_path_prefixes = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This could be a more prominent constant
"uefi-macros/tests/ui/", | ||
]; | ||
|
||
let expected_header = "// SPDX-License-Identifier: MIT OR Apache-2.0\n\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also make this a constant; close to the new constant mentioned above?
// Paths that are missing the file header (only used in check mode). | ||
let mut missing = Vec::new(); | ||
|
||
for path in paths { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could be written more nice
paths.into_iter()
.filter(|path| !exclude_path_prefixes.any(|e| e.startsWith(path)))
.filter(|path| {
let text = fs_err::read_to_string(path)?;
!text.startsWith(expected_header)
})
.forEach(|missing| /* ... */)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for working on this! Left a few remarks
xtask
code for checking/adding SPDX headers.uefi-macros
,uefi-raw
,uefi-test-runner
,uefi
, andxtask
directoriesxtask
header check fatal if any headers are missing.Closes #1511
Checklist