Remove empty lines from git log output

assert_one_change would falsely believe there was a commit when git log returned empty input
because python's strip method returns an array containing an empty string if nothing matches the separator
for example = "".split("\n") returns [''].

I remove empty strings to allow the check to respond to no non-pushed commits

Change-Id: I0d5608acb1728e77f20d9de71c6c23ec4da1c798
This commit is contained in:
Andrew Karnani 2013-10-22 18:54:56 -07:00
parent e79e69f66b
commit df4807a700

View File

@ -528,7 +528,8 @@ def assert_one_change(remote, branch, yes, have_hook):
print("Had trouble running %s" % cmd)
print(output)
sys.exit(1)
output_lines = len(output.split("\n"))
filtered = filter(None, output.split("\n"))
output_lines = sum(1 for s in filtered)
if output_lines == 1 and not have_hook:
printwrap("Your change was committed before the commit hook was "
"installed. Amending the commit to add a gerrit change id.")