-
Notifications
You must be signed in to change notification settings - Fork 188
Customizable copyright string check #103
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ var ( | |
| license = flag.String("l", "apache", "license type: apache, bsd, mit, mpl") | ||
| licensef = flag.String("f", "", "license file") | ||
| year = flag.String("y", fmt.Sprint(time.Now().Year()), "copyright year(s)") | ||
| copyright = flag.String("x", "(c)", "custom copyright string used to determine license header presence") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By defining Is there a reason you chose |
||
| verbose = flag.Bool("v", false, "verbose mode: print the name of the files that are modified") | ||
| checkonly = flag.Bool("check", false, "check only mode: verify presence of license headers and exit with non-zero code if missing") | ||
| ) | ||
|
|
@@ -371,5 +372,6 @@ func hasLicense(b []byte) bool { | |
| } | ||
| return bytes.Contains(bytes.ToLower(b[:n]), []byte("copyright")) || | ||
| bytes.Contains(bytes.ToLower(b[:n]), []byte("mozilla public")) || | ||
| bytes.Contains(bytes.ToLower(b[:n]), []byte("spdx-license-identifier")) | ||
| bytes.Contains(bytes.ToLower(b[:n]), []byte("spdx-license-identifier")) || | ||
| bytes.Contains(bytes.ToLower(b[:n]), []byte(*copyright)) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| © {{.Year}} {{.Holder}} | ||
|
|
||
| Custom License Template |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /* | ||
| * © 2022 Google LLC | ||
| * | ||
| * Custom License Template | ||
| */ | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| printf("Hello world\n"); | ||
| return 0; | ||
| } |
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.
The string "(c)" may result in some false positives, e.g. an
(a) (b) (c)list or a reference to a 501(c)3 organization.