[Asterisk-code-review] testsuite: Check origin branch, not local branch. (repotools[master])

Kevin Harwell asteriskteam at digium.com
Fri May 18 17:21:51 CDT 2018


Kevin Harwell has submitted this change and it was merged. ( https://gerrit.asterisk.org/8909 )

Change subject: testsuite: Check origin branch, not local branch.
......................................................................

testsuite: Check origin branch, not local branch.

When creating a new branch we can't assume that a local
branch will already exist. We have to check that it exists
in the origin remote. The act of checking it out will then
create a local branch.

Change-Id: I9cc8d3c1fc52c76cf93351480f4b460a70ba625e
---
M digium_git.py
M testsuite.py
2 files changed, 15 insertions(+), 2 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, approved; Approved for Submit



diff --git a/digium_git.py b/digium_git.py
index 7cd7c1e..0512642 100644
--- a/digium_git.py
+++ b/digium_git.py
@@ -249,6 +249,19 @@
 
         return name in self.repo.heads
 
+    def origin_branch_exists(self, name):
+        """Determine if a branch exists on the origin
+
+        Keyword Arguments:
+        name - The name of the branch to look for
+
+        Returns:
+        True if the branch exists
+        False if the branch does not
+        """
+
+        return name in self.repo.remotes.origin.refs
+
     def _push_updated_branches(self):
         """Push new or updated branches to the remote repository."""
 
diff --git a/testsuite.py b/testsuite.py
index e60e24a..aa68b3b 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -130,7 +130,7 @@
             # tag(s) should already exist.
             base = version.branch_name(prefix=False)
 
-            if not self.branch_exists(base):
+            if not self.origin_branch_exists(base):
                 # If for some reason the base branch doesn't exist (release
                 # branch was deleted prior to creating the prefixed branch)
                 # then use the latest tag instead.
@@ -144,7 +144,7 @@
             # checkout is always based off the major branch.
             base = str(version.major)
 
-            if not self.branch_exists(base):
+            if not self.origin_branch_exists(base):
                 # Must be a new major version. Create it off of master.
                 super(Testsuite, self).checkout('master')
 

-- 
To view, visit https://gerrit.asterisk.org/8909
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9cc8d3c1fc52c76cf93351480f4b460a70ba625e
Gerrit-Change-Number: 8909
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180518/719617db/attachment-0001.html>


More information about the asterisk-code-review mailing list