Fix UnboundLocalError in CheckLicense.

`current_year` wasn't initialized if `licence_re` is set.
See e.g. https://ci.chromium.org/b/8799737896715431809

R=brucedawson@chromium.org, iannucci@chromium.org
BUG=1098010

Change-Id: Idb1a320af7f4790f2dac0fba7a62e2990a3664e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3969027
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Harald Alvestrand <hta@chromium.org>
changes/27/3969027/2
Vadim Shtayura 3 years ago committed by LUCI CQ
parent 3b9552584d
commit 8e2da91cbb

@ -639,6 +639,8 @@ def CheckLicense(input_api, output_api, license_re=None, project_name=None,
if license_re and license_re == '.*':
return []
current_year = int(input_api.time.strftime('%Y'))
if license_re:
new_license_re = license_re
else:
@ -647,7 +649,6 @@ def CheckLicense(input_api, output_api, license_re=None, project_name=None,
# Accept any year number from 2006 to the current year, or the special
# 2006-20xx string used on the oldest files. 2006-20xx is deprecated, but
# tolerated on old files. On new files the current year must be specified.
current_year = int(input_api.time.strftime('%Y'))
allowed_years = (str(s) for s in reversed(range(2006, current_year + 1)))
years_re = '(' + '|'.join(allowed_years) + '|2006-2008|2006-2009|2006-2010)'

Loading…
Cancel
Save