Skip to content

Commit 28c1e7a

Browse files
authored
Merge pull request kubernetes#134835 from tallclair/copyright-year
Remove year from copyright header boilerplate
2 parents 733f552 + c247514 commit 28c1e7a

File tree

9 files changed

+48
-29
lines changed

9 files changed

+48
-29
lines changed

hack/boilerplate/boilerplate.Dockerfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright YEAR The Kubernetes Authors.
1+
# Copyright The Kubernetes Authors.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

hack/boilerplate/boilerplate.Makefile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright YEAR The Kubernetes Authors.
1+
# Copyright The Kubernetes Authors.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

hack/boilerplate/boilerplate.go.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright YEAR The Kubernetes Authors.
2+
Copyright The Kubernetes Authors.
33

44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

hack/boilerplate/boilerplate.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,11 @@ def file_passes(filename, refs, regexs):
103103
# trim our file to the same number of lines as the reference file
104104
data = data[: len(ref)]
105105

106-
pattern = regexs["year"]
107-
for line in data:
108-
if pattern.search(line):
109-
if generated:
110-
print(
111-
f"File {filename} has the YEAR field, but it should not be in generated file",
112-
file=verbose_out,
113-
)
114-
else:
115-
print(
116-
"File {filename} has the YEAR field, but missing the year of date",
117-
file=verbose_out,
118-
)
119-
return False
120-
121106
if not generated:
122-
# Replace all occurrences of the regex "2014|2015|2016|2017|2018" with "YEAR"
107+
# Remove all occurrences of the year (regex "Copyright (2014|2015|2016|2017|2018) ")
123108
pattern = regexs["date"]
124109
for i, line in enumerate(data):
125-
data[i], found = pattern.subn("YEAR", line)
110+
data[i], found = pattern.subn("Copyright ", line)
126111
if found != 0:
127112
break
128113

@@ -203,18 +188,18 @@ def get_files(extensions):
203188

204189

205190
def get_dates():
206-
years = datetime.datetime.now().year
207-
return "(%s)" % "|".join(str(year) for year in range(2014, years + 1))
191+
# After 2025, we no longer allow new files to include the year in the copyright header.
192+
final_year = 2025
193+
return " (%s) " % "|".join(str(year) for year in range(2014, final_year + 1))
208194

209195

210196
def get_regexs():
211197
regexs = {}
212198
# Search for "YEAR" which exists in the boilerplate, but shouldn't in the real thing
213199
regexs["year"] = re.compile("YEAR")
214-
# get_dates return 2014, 2015, 2016, 2017, or 2018 until the current year
215-
# as a regex like: "(2014|2015|2016|2017|2018)";
216-
# company holder names can be anything
217-
regexs["date"] = re.compile(get_dates())
200+
# get_dates return 2014, 2015, 2016, 2017, ..., 2025
201+
# as a regex like: "(2014|2015|2016|2017|2018|...|2025)";
202+
regexs["date"] = re.compile("Copyright" + get_dates())
218203
# strip the following build constraints/tags:
219204
# //go:build
220205
# // +build \n\n

hack/boilerplate/boilerplate.py.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright YEAR The Kubernetes Authors.
1+
# Copyright The Kubernetes Authors.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

hack/boilerplate/boilerplate.sh.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright YEAR The Kubernetes Authors.
1+
# Copyright The Kubernetes Authors.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

hack/boilerplate/boilerplate_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ class Args:
5050

5151
sys.stdout = old_stdout
5252

53-
self.assertEqual(output, ["././fail.go", "././fail.py"])
53+
self.assertEqual(output, ["././fail.go", "././fail.py", "././fail_2026.go"])

hack/boilerplate/test/fail_2026.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright 2026 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package test
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package test

0 commit comments

Comments
 (0)