-
Notifications
You must be signed in to change notification settings - Fork 169
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 support for SPDX style headers #79
Conversation
Move the logic for selecting a license template based on user input into a standalone func (fetchTemplate), and add test cases for all code paths. Delay parsing predefined license templates. This allows the new fetchTemplate method to modify these templates before returning in the future (to add SPDX license information). Add tests to ensure that these templates must always parse properly. Rename copyrightData type to licenseData, since we will soon begin to add more than just copyright data here (SPDX ID). Rename prefix func to executeTemplate, since this better describes what the function is doing. These are all refactoring and cleanup changes; no behavioral changes.
This adds a new "-s" flag that will append an SPDX-License-Identifier line to license headers. If "-s=only" is specified, then only the SPDX identifier will be used. This also changes the "-l" flag to use SPDX identifiers, with mappings to support the legacy "apache", "mit", and "mpl" values. Together with the "-s" flag, this allows SPDX headers for any arbitrary license type to be added to files. Co-authored-by: Bob Callaway <bcallawa@redhat.com>
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@bobcallaway, see the comment from @google-cla above. Because I listed you as a co-author on one of the commits, you'll need to explicitly consent to submitting this change, even though you've already signed the CLA. |
cc @mco-gh for review |
fmt.Fprintln(os.Stderr, helpText) | ||
flag.PrintDefaults() | ||
} | ||
flag.Var(&skipExtensionFlags, "skip", "To skip files to check/add the header file, for example: -skip rb -skip go") |
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.
Should these two flag.Var lines go in the var block above where the other flags are defined?
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.
no, custom flag parsing using flag.Var
can't be done at initialization time in a var block. Same for the other *Var funcs, flag.StringVar
, flag.IntVar
, etc.
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.
ok, makes sense
@googlebot I consent. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
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.
thanks Will!
Merged but failed to build due to golint errors:
$ golint -set_exit_status ./...
243tmpl.go:71:27: error strings should not be capitalized or end with
punctuation or a newline
244tmpl_test.go:65:15: error strings should not be capitalized or end
with punctuation or a newline
245Found 2 lint suggestions; failing.
246The command "golint -set_exit_status ./..." exited with 1.
…On Tue, 27 Jul 2021 at 18:29, Will Norris ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In main.go
<#79 (comment)>:
> @@ -58,6 +59,15 @@ var (
checkonly = flag.Bool("check", false, "check only mode: verify presence of license headers and exit with non-zero code if missing")
)
+func init() {
+ flag.Usage = func() {
+ fmt.Fprintln(os.Stderr, helpText)
+ flag.PrintDefaults()
+ }
+ flag.Var(&skipExtensionFlags, "skip", "To skip files to check/add the header file, for example: -skip rb -skip go")
no, custom flag parsing using flag.Var can't be done at initialization
time in a var block. Same for the other *Var funcs, flag.StringVar,
flag.IntVar, etc.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#79 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFAXF2CR2TWKI6NL35FX5DTZ3UHPANCNFSM5BBLP5BQ>
.
--
Marc Cohen
Web: mco.dev
Email: ***@***.***
Working with me: mco.dev/working-with-marc
Feedback: How am I doing? Provide anonymous feedback!
<https://www.increment.me/feedback/049628fd-7339-406d-9203-17d3ec8976bd/submit>
Q: Why is this email three sentences or less?
A: three.sentenc.es
|
My next PR will be to migrate CI over to GitHub Actions, setup better linting, etc :) |
This PR implements the changes described in #77 (comment). This contains two commits, which might be easier to review individually. The first is just a refactor and slight cleanup of existing code with no change in behavior. These changes make it easier to add SPDX support as well as begin to decouple certain logic to make testing simpler. The second commit actually adds support for SPDX headers as discussed in #77.
Closes #77