Unverified Commit f7d9fb47 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #60866 from fisherxu/autodate

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Auto check the current year in boilerplate **What this PR does / why we need it**: Every new year we need to add the current year to boilerplate.py manually like #[Update boilerplate for 2018](https://github.com/kubernetes/kubernetes/commit/bec420875ea5c64a9c4fa1269ada2a856b3d5ab7#diff-0f66228ea46785f57b8df9ca08b23f49), #[Update boilerplate.py to support 2017](https://github.com/kubernetes/kubernetes/commit/98534200bce7d2e039d6f127af828bd64dfe6086#diff-0f66228ea46785f57b8df9ca08b23f49), it should be auto checked. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # [Update boilerplate for 2018](https://github.com/kubernetes/kubernetes/commit/bec420875ea5c64a9c4fa1269ada2a856b3d5ab7#diff-0f66228ea46785f57b8df9ca08b23f49) , #[Update boilerplate.py to support 2017](https://github.com/kubernetes/kubernetes/commit/98534200bce7d2e039d6f127af828bd64dfe6086#diff-0f66228ea46785f57b8df9ca08b23f49) **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents c6ae1e51 334c2fdc
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment