Skip to content

Commit bae93ee

Browse files
committed
Add SPDX-Copyright-Text tag
Signed-off-by: Adam Moss <[email protected]>
1 parent 4af9285 commit bae93ee

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ repos:
66
- repo: https://github.com/hashicorp/copywrite
77
rev: v0.15.0 # Use any release tag
88
hooks:
9-
- id: copywrite-headers
9+
- id: check-headers
1010
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v2.3.0
11+
rev: v4.4.0
1212
hooks:
1313
- id: end-of-file-fixer
1414
exclude: ^addLicense/testdata/
1515
- id: trailing-whitespace
1616
exclude: ^addLicense/testdata/
1717
- repo: https://github.com/dnephin/pre-commit-golang
18-
rev: v0.5.0
18+
rev: v0.5.1
1919
hooks:
2020
- id: go-fmt
2121
- id: go-vet

addlicense/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ func walk(ch chan<- *file, start string, logger *log.Logger) error {
295295
// Patterns are assumed to be valid.
296296
func fileMatches(path string, patterns []string) bool {
297297
for _, p := range patterns {
298-
298+
299299
if runtime.GOOS == "windows" {
300300
// If on windows, change path seperators to /
301-
// in order for patterns to compare correctly
301+
// in order for patterns to compare correctly
302302
path = filepath.ToSlash(path)
303303
}
304-
304+
305305
// ignore error, since we assume patterns are valid
306306
if match, _ := doublestar.Match(p, path); match {
307307
return true
@@ -451,7 +451,7 @@ func hasLicense(b []byte) bool {
451451
if len(b) < 1000 {
452452
n = len(b)
453453
}
454-
return bytes.Contains(bytes.ToLower(b[:n]), []byte("copyright")) ||
454+
return bytes.Contains(bytes.ToLower(b[:n]), []byte("spdx-filecopyrighttext")) ||
455455
bytes.Contains(bytes.ToLower(b[:n]), []byte("mozilla public")) ||
456456
bytes.Contains(bytes.ToLower(b[:n]), []byte("spdx-license-identifier"))
457457
}

addlicense/tmpl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ const tmplMPL = `This Source Code Form is subject to the terms of the Mozilla Pu
144144
License, v. 2.0. If a copy of the MPL was not distributed with this
145145
file, You can obtain one at https://mozilla.org/MPL/2.0/.`
146146

147-
const tmplSPDX = `Copyright (c){{ if .Year }} {{.Year}}{{ end }}{{ if .Holder }} {{.Holder}}{{ end }}
147+
const tmplSPDX = `SPDX-FileCopyrightText: Copyright (c){{ if .Year }} {{.Year}}{{ end }}{{ if .Holder }} {{.Holder}}{{ end }}
148148
{{ if .SPDXID }}SPDX-License-Identifier: {{.SPDXID}}{{ end }}`
149149

150-
const tmplCopyrightOnly = `Copyright (c){{ if .Year }} {{.Year}}{{ end }}{{ if .Holder }} {{.Holder}}{{ end }}`
150+
const tmplCopyrightOnly = `SPDX-FileCopyrightText: Copyright (c){{ if .Year }} {{.Year}}{{ end }}{{ if .Holder }} {{.Holder}}{{ end }}`
151151

152152
const spdxSuffix = "\n\nSPDX-License-Identifier: {{.SPDXID}}"

0 commit comments

Comments
 (0)