-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Create lit test for copyright header validation #15296
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "cya-\u{1F469}\u{1F3FB}\u200D\u2696\uFE0F"
Conversation
This could be useful as a script in swift/utils, for updating the copyright notices of all source files. It could use the For example, the commit logs for Bool.swift will end with:
git log \
--find-renames=33% \
--follow \
-- "./stdlib/public/core/Bool.swift" I've filed SR-7507 to improve the code templates, so that new source files can use |
433ada1
to
49dc4ae
Compare
@@ -0,0 +1,3 @@ | |||
// Checks to make sure all copyright headers conform with their | |||
// git creation/last modification date for silly legal reasons. |
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.
Please remove the text "for silly legal reasons". Only lawyers are allowed to opine on whether legal issues are silly or not. 😄
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.
quite sage
committed 👍
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
Looks like we have a source file somewhere that has malformed UTF-8? Unfortunately, the script just crashes without reporting the name of the file. We should fix that.
|
utils/copyright-conformance.py
Outdated
def has_copyright_notice(candidate_filepath): | ||
"""Checks if a file has a copyright notice""" | ||
with open(candidate_filepath, "r") as f: | ||
contents = f.read() |
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.
This line can fail. We should catch any error that happens here and print out the candidate_filepath
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.
yup, i see. it looks like some non-unicode files have been added to the tree in the last 4 years
i've pushed a change that skips all files that fail to read with a non-unicode error
Script that changes copyright headers to conform to their git creation/modification dates
@tbkka i also went ahead and rebased, then tested the script. it corrected 8785 files, you can see them here AndrewSB@1621206 once this is merged, i'll open that as another PR |
cc @gottesmm @shahmishal
I think I have this working when I pass one file into the script, whats the right way to spell "give me all the files so I can
xargs
them into a script" in lit?