]> git.ipfire.org Git - thirdparty/u-boot.git/blobdiff - scripts/mailmapper
Merge branch 'next' of https://source.denx.de/u-boot/custodians/u-boot-riscv into...
[thirdparty/u-boot.git] / scripts / mailmapper
index dd1ddf6a712fd424942bf7ffb56d17587bc12dfb..0e744ec1a0b8f0af6267fad9ca157adf00c800b6 100755 (executable)
@@ -1,9 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0+
 #
 # Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
 
 '''
 A tool to create/update the mailmap file
@@ -59,8 +57,7 @@ MIN_COMMITS = 50
 try:
     toplevel = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'])
 except subprocess.CalledProcessError:
-    print >> sys.stderr, 'Please run in a git repository.'
-    sys.exit(1)
+    sys.exit('Please run in a git repository.')
 
 # strip '\n'
 toplevel = toplevel.rstrip()
@@ -92,9 +89,10 @@ output = {}
 for line in shortlog.splitlines():
     # tmp, mail = line.rsplit(None, 1) is not safe
     # because weird email addresses might include whitespaces
-    tmp, mail = line.split('<')
-    mail = '<' + mail.rstrip()
     try:
+        line = line.decode("utf-8")
+        tmp, mail = line.split('<')
+        mail = '<' + mail.rstrip()
         _, name = tmp.rstrip().split(None, 1)
     except ValueError:
         # author name is empty
@@ -103,8 +101,11 @@ for line in shortlog.splitlines():
         # another name for the same email address
         prev_name = mail_vs_name[mail]
         # Take the name with more commits
-        major_name = sorted([prev_name, name],
-                            key=lambda x: commits_per_name[x] if x else 0)[1]
+        try:
+            major_name = sorted([prev_name, name],
+                                key=lambda x: commits_per_name[x] if x else 0)[1]
+        except:
+            continue
         mail_vs_name[mail] = major_name
         if commits_per_name[major_name] > MIN_COMMITS:
             output[mail] = major_name