diff --git a/hack/boilerplate/boilerplate.py b/hack/boilerplate/boilerplate.py index 9ff1d776da3..7165d8e67b3 100755 --- a/hack/boilerplate/boilerplate.py +++ b/hack/boilerplate/boilerplate.py @@ -17,6 +17,7 @@ from __future__ import print_function import argparse +import datetime import difflib import glob import json @@ -171,12 +172,17 @@ def get_files(extensions): outfiles.append(pathname) return outfiles +def get_dates(): + years = datetime.datetime.now().year + return '(%s)' % '|'.join((str(year) for year in range(2014, years+1))) + def get_regexs(): regexs = {} # Search for "YEAR" which exists in the boilerplate, but shouldn't in the real thing regexs["year"] = re.compile( 'YEAR' ) - # dates can be 2014, 2015, 2016, 2017, or 2018; company holder names can be anything - regexs["date"] = re.compile( '(2014|2015|2016|2017|2018)' ) + # get_dates return 2014, 2015, 2016, 2017, or 2018 until the current year as a regex like: "(2014|2015|2016|2017|2018)"; + # company holder names can be anything + regexs["date"] = re.compile(get_dates()) # strip // +build \n\n build constraints regexs["go_build_constraints"] = re.compile(r"^(// \+build.*\n)+\n", re.MULTILINE) # strip #!.* from shell scripts