From 74ff6d514fd5723c3b038179f63f7741efaa1096 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 26 Sep 2013 06:28:16 -0400 Subject: [PATCH] Refactor the repository probe code. --- coverity-submit | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/coverity-submit b/coverity-submit index 1296eca..0ae94be 100755 --- a/coverity-submit +++ b/coverity-submit @@ -10,16 +10,17 @@ version = "1.10" def commit_id(): "If we're in a repository directory, try to extract a commit description." - if os.system("git rev-parse HEAD >/dev/null 2>&1") == 0: - (status, output) = commands.getstatusoutput("git describe HEAD") - elif os.system("hg root >/dev/null 2>&1") == 0: - (status, output) = commands.getstatusoutput("hg --id") - elif os.system("bzr root >/dev/null 2>&1") == 0: - (status, output) = commands.getstatusoutput("bzr version-info --custom --template='{revision_id}\n'") - elif os.system("svn info >/dev/null 2>&1") == 0: - (status, output) = commands.getstatusoutput("svnversion") - if status == 0: - return output + methods = ( + ("git rev-parse HEAD", "git describe HEAD"), + ("hg root", "hg --id"), + ("bzr root", "bzr version-info --custom --template='{revision_id}\n'"), + ("svn info", "svnversion") + ) + for (probe, extract) in methods: + if os.system(probe + " >/dev/null 2>&1") == 0: + (status, output) = commands.getstatusoutput(extract) + if status == 0: + return output return None def deduce_name(): -- 2.43.0