Skip to content

Commit cfe19e3

Browse files
authored
Update logic for copywrite header
1 parent 9d021bf commit cfe19e3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

addlicense/main.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,14 @@ func hasLicense(b []byte) bool {
488488
if len(b) < 1000 {
489489
n = len(b)
490490
}
491-
return bytes.Contains(bytes.ToLower(b[:n]), []byte("copyright")) ||
492-
bytes.Contains(bytes.ToLower(b[:n]), []byte("mozilla public")) ||
493-
bytes.Contains(bytes.ToLower(b[:n]), []byte("spdx-license-identifier"))
491+
// Convert to lowercase for case-insensitive matching
492+
content := bytes.ToLower(b[:n])
493+
494+
// Check for different variations of copyright/license headers
495+
return bytes.Contains(content, []byte("copyright")) ||
496+
bytes.Contains(content, []byte("copyright (c)")) ||
497+
bytes.Contains(content, []byte("the opentofu authors")) ||
498+
bytes.Contains(content, []byte("hashicorp, inc.")) ||
499+
bytes.Contains(content, []byte("mozilla public")) ||
500+
bytes.Contains(content, []byte("spdx-license-identifier"))
494501
}

0 commit comments

Comments
 (0)