@@ -76,12 +76,6 @@ def get_refs():
7676
7777 return refs
7878
79- # given the file contents, return true if the file appears to be generated
80- def is_generated (data ):
81- if re .search (r"^// Code generated by .*\. DO NOT EDIT\.$" , data , re .MULTILINE ):
82- return True
83- return False
84-
8579
8680def file_passes (filename , refs , regexs ): # pylint: disable=too-many-locals
8781 try :
@@ -123,22 +117,10 @@ def file_passes(filename, refs, regexs): # pylint: disable=too-many-locals
123117 # trim our file to the same number of lines as the reference file
124118 data = data [:len (ref )]
125119
126- # check if we encounter a 'YEAR' placeholder if the file is generated
127- if is_generated (file_data ):
128- for i , line in enumerate (data ):
129- if "Copyright YEAR" in line :
130- return False
131- return True
132-
133- year = regexs ["year" ]
134- for datum in data :
135- if year .search (datum ):
136- return False
137-
138- # Replace all occurrences of the regex "2017|2016|2015|2014" with "YEAR"
120+ # Replace all occurrences of the regex "Copyright 2017 |Copyright " with "Copyright "
139121 when = regexs ["date" ]
140122 for idx , datum in enumerate (data ):
141- (data [idx ], found ) = when .subn ('YEAR ' , datum )
123+ (data [idx ], found ) = when .subn ('Copyright ' , datum )
142124 if found != 0 :
143125 break
144126
@@ -211,16 +193,13 @@ def get_files(extensions):
211193
212194
213195def get_dates ():
214- years = datetime .datetime .now ().year
215- return '(%s)' % '|' .join ((str (year ) for year in range (2014 , years + 1 )))
196+ return '((201[4-9]|202[0-5]) )?'
216197
217198
218199def get_regexs ():
219200 regexs = {}
220- # Search for "YEAR" which exists in the boilerplate, but shouldn't in the real thing
221- regexs ["year" ] = re .compile ('YEAR' )
222- # dates can be any year between 2014 and the current year, company holder names can be anything
223- regexs ["date" ] = re .compile (get_dates ())
201+ # dates can be any year between 2014 and 2025, company holder names can be anything
202+ regexs ["date" ] = re .compile (r'Copyright ' + get_dates ())
224203 # strip // +build \n\n build constraints
225204 regexs ["go_build_constraints" ] = re .compile (r"^(//( \+build|go:build).*\n)+\n" ,
226205 re .MULTILINE )
0 commit comments