From 09a7d3c05d234bf5cba54bd1061fff158c2610c9 Mon Sep 17 00:00:00 2001 From: tenzap Date: Sat, 2 Oct 2021 13:55:53 +0200 Subject: [PATCH] fix update-copyright when there is only year without author Otherwise the script would fail on this file: qtlocation/src/3rdparty/mapbox-gl-native/deps/boost/1.65.1/include/boost/preprocessor/cat.hpp Which matches this (author is not mentioned) : Copyright (C) 2001 Error reported before the fix: File ".../debian/scripts/update-copyright", line 114, in parse_file if copyright[4] == '-': IndexError: string index out of range --- debian/scripts/update-copyright | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/debian/scripts/update-copyright b/debian/scripts/update-copyright index 207e49c..6dd0236 100755 --- a/debian/scripts/update-copyright +++ b/debian/scripts/update-copyright @@ -108,14 +108,17 @@ def parse_file(filename): if match: copyright = match.group(1) max_year = min_year = int(copyright[:4]) - if copyright[4] == '-': - max_year = int(copyright[5:9]) - author = copyright[10:] - elif copyright[4:7] == ' - ': - max_year = int(copyright[7:11]) - author = copyright[12:] + if len(copyright) >= 5: + if copyright[4] == '-': + max_year = int(copyright[5:9]) + author = copyright[10:] + elif copyright[4:7] == ' - ': + max_year = int(copyright[7:11]) + author = copyright[12:] + else: + author = copyright[5:] else: - author = copyright[5:] + author = "" author = canonicalize_author_name(author) authors.append((min_year, max_year, author)) match = header_re.search(line)