-
Notifications
You must be signed in to change notification settings - Fork 189
feat: add headers to Makefiles also #147
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
993e1fb
ef1869c
8efd1db
c942ac3
a459904
21343c7
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 |
|---|---|---|
|
|
@@ -315,6 +315,8 @@ func licenseHeader(path string, tmpl *template.Template, data licenseData) ([]by | |
| // handle various cmake files | ||
| if base == "cmakelists.txt" || strings.HasSuffix(base, ".cmake.in") || strings.HasSuffix(base, ".cmake") { | ||
| lic, err = executeTemplate(tmpl, data, "", "# ", "") | ||
| } else if base == "Makefile" || base == "makefile" || strings.HasSuffix(base, ".mk") { // handle various make files | ||
|
Contributor
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. cmake needs special support because it needs to look at multiple parts of the filename. I think you can just add this to the case statement above, similar to Gemfile. |
||
| lic, err = executeTemplate(tmpl, data, "", "# ", "") | ||
| } | ||
| } | ||
| return lic, err | ||
|
|
@@ -374,7 +376,11 @@ func hasLicense(b []byte) bool { | |
| if len(b) < 1000 { | ||
| n = len(b) | ||
| } | ||
| return bytes.Contains(bytes.ToLower(b[:n]), []byte("copyright")) || | ||
| return bytes.Contains(bytes.ToLower(b[:n]), []byte("# copyright")) || | ||
|
Contributor
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. This change doesn't seem necessary: "# copyright" also contains the string "copyright". |
||
| bytes.Contains(bytes.ToLower(b[:n]), []byte("copyright ")) || | ||
| bytes.Contains(bytes.ToLower(b[:n]), []byte("// copyright")) || | ||
| bytes.Contains(bytes.ToLower(b[:n]), []byte("/* copyright")) || | ||
| 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")) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -340,7 +340,7 @@ func TestLicenseHeader(t *testing.T) { | |
| "(**\n HYS\n*)\n\n", | ||
| }, | ||
| { | ||
| []string{"cmakelists.txt", "f.cmake", "f.cmake.in"}, | ||
| []string{"cmakelists.txt", "f.cmake", "f.cmake.in", "makefile", "Makefile", "f.mk"}, | ||
|
Contributor
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. Create a separate test group for makefiles; they're different than cmake. |
||
| "# HYS\n\n", | ||
| }, | ||
|
|
||
|
|
@@ -395,6 +395,10 @@ func TestHasLicense(t *testing.T) { | |
|
|
||
| {"Copyright 2000", true}, | ||
| {"CoPyRiGhT 2000", true}, | ||
| {"// Copyright 2000", true}, | ||
| {"# CopyRight 2000", true}, | ||
| {"/*\n * CopyRight 2000", true}, | ||
| {"// SPDX-License-Identifier: MIT", true}, | ||
| {"Subject to the terms of the Mozilla Public License", true}, | ||
| {"SPDX-License-Identifier: MIT", true}, | ||
| {"spdx-license-identifier: MIT", true}, | ||
|
|
||
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 revert the changes to this file.