changeset 8310:d6ccf6a9fd11

scripts: fix crash from comparing integer with empty list Fixed by using year 0 as default for contributors without any years.
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 28 Mar 2020 15:29:58 +0100
parents 68bbfd164b23
children 9757ad98ea09
files scripts/update-copyrights.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/update-copyrights.py	Sat Mar 28 15:28:25 2020 +0100
+++ b/scripts/update-copyrights.py	Sat Mar 28 15:29:58 2020 +0100
@@ -52,10 +52,13 @@
     * number of contribution years
     * name (with some unicode normalization)
     The entries must be 2-tuples of a list of string years and the name"""
-    return (x[0] and -int(x[0][-1]),
-            x[0] and int(x[0][0]),
-            -len(x[0]),
-            x[1].decode('utf-8').lower().replace('\xe9', 'e').replace('\u0142', 'l')
+    years, name = x
+    if not years:
+        years = ['0']
+    return (-int(years[-1]),  # primarily sort by latest contribution
+            int(years[0]),  # then sort by first contribution
+            -len(years),  # then sort by length of contribution (no gaps)
+            name.lower().replace('\xe9', 'e').replace('\u0142', 'l')  # finally sort by name
         )