]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
scripts: avoid error in DCO check on empty branches
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 27 Mar 2020 14:38:49 +0000 (14:38 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 27 Mar 2020 15:12:48 +0000 (15:12 +0000)
If the DCO check is run on an empty branch (ie one which has no commits
different from master), it throws an error due to trying to interpret
the empty string as a git commit SHA.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
scripts/require-dco.py

index 9fe13823a9d7df0dffe2c5fe50e52c45f08f3546..ae943933196370a616ce0e52c026c8422a408d2a 100755 (executable)
@@ -46,7 +46,10 @@ print("\nChecking for 'Signed-off-by: NAME <EMAIL>' on all commits since %s...\n
 log = subprocess.check_output(["git", "log", "--format=%H %s", ancestor + "..."],
                               universal_newlines=True)
 
-commits = [[c[0:40], c[41:]] for c in log.strip().split("\n")]
+if log == "":
+    commits = []
+else:
+    commits = [[c[0:40], c[41:]] for c in log.strip().split("\n")]
 
 for sha, subject in commits: