Skip to content

Commit 2b64bb3

Browse files
committed
Handle old-style build lines for copyright
1 parent 130c636 commit 2b64bb3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

hack/boilerplate/boilerplate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
skippedPaths = regexp.MustCompile(`Godeps|third_party|_gopath|_output|\.git|cluster/env.sh|vendor|test/e2e/generated/bindata.go|site/themes/docsy|test/integration/testdata|hack/benchmark/image-build/minikube-image-benchmark|hack/benchmark/time-to-k8s/time-to-k8s-repo`)
3535
windowdNewLine = regexp.MustCompile(`\r`)
3636
txtExtension = regexp.MustCompile(`\.txt`)
37-
goBuildTag = regexp.MustCompile(`(?m)^(//go:build.*\n)+\n`)
37+
goBuildTag = regexp.MustCompile(`(?m)^(//go:build.*\n|// +build.*\n)+\n`)
3838
shebang = regexp.MustCompile(`(?m)^(#!.*\n)\n*`)
3939
copyright = regexp.MustCompile(`Copyright YEAR`)
4040
copyrightReal = regexp.MustCompile(`Copyright \d{4}`)

hack/boilerplate/fix.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ function prepend() {
3030
local file_headers=""
3131

3232
if [ "${headers}" != "" ]; then
33-
file_headers="$(cat ${f} | grep ${headers})"
33+
file_headers="$(cat ${f} | grep -E ${headers})"
3434
fi
3535

3636
if [ "${file_headers}" != "" ]; then
37-
fileContent="$(cat ${f} | grep -v ${headers})"
37+
fileContent="$(cat ${f} | grep -v -E ${headers})"
3838
printf '%s\n\n%s\n%s\n' "$file_headers" "${copyright}" "$fileContent" > ${f}
3939
else
4040
fileContent="$(cat ${f})"
@@ -44,7 +44,7 @@ function prepend() {
4444
done
4545
}
4646

47-
prepend "\.go" "go" "go:build"
47+
prepend "\.go" "go" "go:build|\+build"
4848
prepend "\.py" "py"
4949
prepend "\.sh" "sh" "#!"
5050
prepend Makefile Makefile

0 commit comments

Comments
 (0)