Skip to content

Commit ee7407c

Browse files
committed
Fix crash when licenseupdate.py can't find a '{year}' in .styleguide-license
This gives __try_regex() the same behavior as __try_string_search(), which defaults the first year to the last year in the copyright range.
1 parent fed03cd commit ee7407c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

wpiformat/wpiformat/licenseupdate.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def __try_regex(self, lines, last_year, license_template):
4040
r"(?P<year>[0-9]+)(-[0-9]+)?").replace("{padding}", "[ ]*")
4141
license_rgx = regex.compile(license_rgxstr, regex.M)
4242

43+
first_year = last_year
44+
4345
# Compare license
4446
match = license_rgx.search(lines)
4547
if match:
@@ -51,7 +53,7 @@ def __try_regex(self, lines, last_year, license_template):
5153
# If comment at beginning of file is non-empty license, update it
5254
return (True, first_year, linesep + lines[match.end():].lstrip())
5355
else:
54-
return (False, last_year, lines)
56+
return (False, first_year, lines)
5557

5658
def __try_string_search(self, lines, last_year, license_template):
5759
"""Try finding license with string search.

0 commit comments

Comments
 (0)