google / addlicense

A program which ensures source code files have copyright license headers by scanning directory patterns recursively
Apache License 2.0
716 stars 169 forks source link

Add support for SPDX style headers #79

Closed willnorris closed 3 years ago

willnorris commented 3 years ago

This PR implements the changes described in https://github.com/google/addlicense/pull/77#issuecomment-886240907. 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

google-cla[bot] commented 3 years ago

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 @googlebot I consent. in this pull request.

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 cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

willnorris commented 3 years ago

@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.

willnorris commented 3 years ago

cc @mco-gh for review

bobcallaway commented 3 years ago

@googlebot I consent.

google-cla[bot] commented 3 years ago

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 @googlebot I consent. in this pull request.

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 cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

mco-gh commented 3 years ago

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 https://github.com/google/addlicense/pull/79#discussion_r677657811:

@@ -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 https://github.com/google/addlicense/pull/79#discussion_r677657811, 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

willnorris commented 3 years ago

My next PR will be to migrate CI over to GitHub Actions, setup better linting, etc :)