Merger: support for finding branches in remote
The new merger.hasBranch() method let us find out whether the remote
repository has the given branch. That is probably of no use for Zuul
merger itself but will let me reproduce the devstack-gate
git_has_branch() bash function.
Change-Id: Ibca58172a7b41b1c6b63cdd4449a647020bad0c9
diff --git a/zuul/merger/merger.py b/zuul/merger/merger.py
index b2bc994..359b3ad 100644
--- a/zuul/merger/merger.py
+++ b/zuul/merger/merger.py
@@ -95,6 +95,11 @@
branch_head = repo.heads[branch]
return branch_head.commit
+ def hasBranch(self, branch):
+ repo = self.createRepoObject()
+ origin = repo.remotes.origin
+ return branch in origin.refs
+
def getCommitFromRef(self, refname):
repo = self.createRepoObject()
if not refname in repo.refs: