[Patchew-devel] [PATCH] importer: fix handling of missing commits
Paolo Bonzini
pbonzini at redhat.com
Fri Mar 15 16:51:21 UTC 2019
If the master branch is force-pushed and the old HEAD is not present in the
repository, patchew-cli is currently overwriting the old_head in an
attempt to make the subsequent "git log" command work. However, this
caused a "wrong old head" exception in the project update command.
Instead, leave the old_head unchanged and use the new commits to build a
"git show" command line. This works because the new commits are initialized
to a sane value if the master branch is force-pushed.
Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
---
patchew-cli | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/patchew-cli b/patchew-cli
index 73b8ccf..7fa7d49 100755
--- a/patchew-cli
+++ b/patchew-cli
@@ -308,15 +308,14 @@ class ProjectCommand(SubCommand):
"%s..%s" % (old_head, new_head)],
cwd=clone).decode().splitlines()
except:
- old_head = new_head
new_commits = [new_head]
logging.debug("old head: %s", old_head)
logging.debug("new commits: \n%s" % \
"\n".join([" " + x for x in new_commits]))
- output = subprocess.check_output("""git log --format=%%b %s..%s |
+ output = subprocess.check_output("""git show --format=%%b %s |
awk 'BEGIN{IGNORECASE=1} /^message-id:/{print}'
"""% \
- (old_head, new_head), shell=True, cwd=clone).decode()
+ ' '.join(new_commits), shell=True, cwd=clone).decode()
msgids = [x[len("message-id:"):].strip() for x in output.splitlines()]
logging.debug("message ids: \n%s" % \
"\n".join([" " + x for x in msgids]))
--
2.20.1
More information about the Patchew-devel
mailing list