@@ -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
205190def 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
210196def 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
0 commit comments