Fix branch test for merge script.
authormachenbach <machenbach@chromium.org>
Tue, 17 Feb 2015 11:40:03 +0000 (03:40 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 17 Feb 2015 11:40:18 +0000 (11:40 +0000)
Failing calls to show-ref cause an exception in python.

BUG=chromium:451975
TBR=tandrii@chromium.org
NOTRY=true
LOG=n

TEST=./script_test.py

Review URL: https://codereview.chromium.org/933523003

Cr-Commit-Position: refs/heads/master@{#26684}

tools/release/common_includes.py

index 03b0c5b7d49fc3fe9d4149523e5da2b4af5c86af..bae05bc6b542a2c41d4bb9773bc8ecfc3fc97068 100644 (file)
@@ -338,12 +338,18 @@ class GitInterface(VCInterface):
       return name
     if name in ["candidates", "master"]:
       return "refs/remotes/origin/%s" % name
-    # Check if branch is in heads.
-    if self.step.Git("show-ref refs/remotes/origin/%s" % name).strip():
-      return "refs/remotes/origin/%s" % name
-    # Check if branch is in branch-heads.
-    if self.step.Git("show-ref refs/remotes/branch-heads/%s" % name).strip():
-      return "refs/remotes/branch-heads/%s" % name
+    try:
+      # Check if branch is in heads.
+      if self.step.Git("show-ref refs/remotes/origin/%s" % name).strip():
+        return "refs/remotes/origin/%s" % name
+    except GitFailedException:
+      pass
+    try:
+      # Check if branch is in branch-heads.
+      if self.step.Git("show-ref refs/remotes/branch-heads/%s" % name).strip():
+        return "refs/remotes/branch-heads/%s" % name
+    except GitFailedException:
+      pass
     self.Die("Can't find remote of %s" % name)
 
   def Tag(self, tag, remote, message):