summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2011-02-17 18:27:32 -0700
committerJesse Keating <jkeating@redhat.com>2011-02-18 12:04:27 -0700
commitb7996b83ebe280a3558c035fc9c56d5cfba2cdf9 (patch)
treecaaa0fe48392de56511fd752911f63a50e30df9c
parent4c7436440b4687e618347929ce9ac054acbb319c (diff)
downloadfedora-packager-b7996b83ebe280a3558c035fc9c56d5cfba2cdf9.tar.gz
fedora-packager-b7996b83ebe280a3558c035fc9c56d5cfba2cdf9.tar.xz
fedora-packager-b7996b83ebe280a3558c035fc9c56d5cfba2cdf9.zip
Improve the way we detect branch data
Not only does this now work with old/new style branches, but it also fixed up some improper regex use that could have caught too much. It can be simplified once the branch renames are done.
-rw-r--r--src/pyfedpkg/__init__.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index ac28178..0b00487 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -1069,7 +1069,7 @@ class PackageModule:
raise FedpkgError('Unable to find remote branch. Use --dist')
# Trim off the refs/heads so that we're just working with the branch
# name
- merge = merge.strip('refs/heads/')
+ merge = merge.replace('refs/heads/', '')
# Search for one of our known branches, raise if we can't find one
# to deal with
if re.match(BRANCHRE, merge):
@@ -1092,15 +1092,20 @@ class PackageModule:
# catch branches such as f14-foobar
branchre = 'f\d\d$'
+ # Create another regex for the older style branches that have /master
+ oldbranchre = 'f\d\d\/master$'
+
# Find the repo refs
for ref in self.repo.refs:
# Only find the remote refs
if type(ref) == git.refs.RemoteReference:
- # grab the top level name
- branch = ref.name.split('/')[1]
- if re.match(branchre, branch):
- # Add it to the fedoras
- fedoras.append(branch)
+ # Search for branch name by splitting off the remote
+ # part of the ref name and returning the rest. This may
+ # fail if somebody names a remote with / in the name...
+ if re.match(branchre, ref.name.split('/', 1)[1]) or \
+ re.match(oldbranchre, ref.name.split('/', 1)[1]):
+ # Add just the simple f## part to the list
+ fedoras.append(ref.name.split('/')[1])
if fedoras:
# Sort the list
fedoras.sort()