8000 feat: add headers to Makefiles also by zhouzaihang · Pull Request #147 · google/addlicense · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

zhouzaihang
Copy link

Ensure makefiles also get license headers.

Copy link
Collaborator
@flwyd flwyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sync your branch with master, too.

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -2,6 +2,11 @@ FROM golang:1.16 AS build

WORKDIR /app

# set env
RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct
Copy link
Collaborator

Please revert the changes to this file.

@@ -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")) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem necessary: "# copyright" also contains the string "copyright".

@@ -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"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a separate test group for makefiles; they're different than cmake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0