Skip to content

Commit

Permalink
Merge sigma-star/buildbot:tryclient-git-branches-fix (PR #1158)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jun 3, 2014
2 parents 0c0681b + bb517c6 commit 70812a8
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions master/buildbot/clients/tryclient.py
Expand Up @@ -300,20 +300,32 @@ class GitExtractor(SourceStampExtractor):

def getBaseRevision(self):
# If a branch is specified, parse out the rev it points to
# and extract the local name (assuming it has a slash).
# This may break if someone specifies the name of a local
# branch that has a slash in it and has no corresponding
# remote branch (or something similarly contrived).
# and extract the local name.
if self.branch:
d = self.dovc(["rev-parse", self.branch])
if '/' in self.branch:
self.branch = self.branch.split('/', 1)[1]
d.addCallback(self.override_baserev)
d.addCallback(self.extractLocalBranch)
return d
d = self.dovc(["branch", "--no-color", "-v", "--no-abbrev"])
d.addCallback(self.parseStatus)
return d

# remove remote-prefix from self.branch (assumes format <prefix>/<branch>)
# this uses "git remote" to retrieve all configured remote names
def extractLocalBranch(self, res):
if '/' in self.branch:
d = self.dovc(["remote"])
d.addCallback(self.fixBranch)
return d

# strip remote prefix from self.branch
def fixBranch(self, remotes):
for l in remotes.split("\n"):
r = l.strip()
if r and self.branch.startswith(r):
self.branch = self.branch[len(r) + 1:]
break

def readConfig(self):
if self.config:
return defer.succeed(self.config)
Expand Down

0 comments on commit 70812a8

Please sign in to comment.