diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d4206a7..3907acab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ CLI command and its behaviour. There are no guarantees of stability for the - Reduced python-debian minimum version to 0.1.34. (#808) - Fix issue in `annotate` where `--single-line` and `--multi-line` would not correctly raise an error with an incompatible comment style. (#853) +- Fix parsing existing copyright lines when they do not have a year (#861) ### Security diff --git a/src/reuse/_util.py b/src/reuse/_util.py index 676762b76..7a410d5f3 100644 --- a/src/reuse/_util.py +++ b/src/reuse/_util.py @@ -295,9 +295,9 @@ def _parse_copyright_year(year: str) -> list: """Parse copyright years and return list.""" if not year: ret = [] - if re.match(r"\d{4}$", year): + elif re.match(r"\d{4}$", year): ret = [int(year)] - if re.match(r"\d{4} ?- ?\d{4}$", year): + elif re.match(r"\d{4} ?- ?\d{4}$", year): ret = [int(year[:4]), int(year[-4:])] return ret @@ -393,7 +393,9 @@ def merge_copyright_lines(copyright_lines: Set[str]) -> Set[str]: years += copy["year"] year: Optional[str] = None - if min(years) == max(years): + if not years: + year = None + elif min(years) == max(years): year = min(years) else: year = f"{min(years)} - {max(years)}"