[libvirt PATCH] scripts: avoid error in DCO check on empty branches

Daniel P. Berrangé posted 1 patch 4 years ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20200327144150.15112-1-berrange@redhat.com
scripts/require-dco.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[libvirt PATCH] scripts: avoid error in DCO check on empty branches
Posted by Daniel P. Berrangé 4 years ago
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.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 scripts/require-dco.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/require-dco.py b/scripts/require-dco.py
index 9fe13823a9..ae94393319 100755
--- a/scripts/require-dco.py
+++ b/scripts/require-dco.py
@@ -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:
 
-- 
2.24.1

Re: [libvirt PATCH] scripts: avoid error in DCO check on empty branches
Posted by Andrea Bolognani 4 years ago
On Fri, 2020-03-27 at 14:41 +0000, Daniel P. Berrangé wrote:
> 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.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  scripts/require-dco.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization