From 2748ee33fcd130c67c51d2fe06c05c35186c6e30 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Thu, 17 Feb 2011 18:23:21 -0700 Subject: Add new and old support to switch_branches This also removes a hardcoded reference to "origin", as this can be named differently. --- src/pyfedpkg/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index f3f3fc8..4816e6e 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -874,11 +874,15 @@ def switch_branch(branch, path=None): if not branch in locals: # We need to create a branch log.debug('No local branch found, creating a new one') - if not 'origin/%s/master' % branch in remotes: + totrack = None + for remote in remotes: + if remote.endswith(branch) or remote.endswith(branch + '/master'): + totrack = remote + break + else: raise FedpkgError('Unknown remote branch %s' % branch) try: - log.info(repo.git.checkout('-b', branch, '--track', - 'origin/%s/master' % branch)) + log.info(repo.git.checkout('-b', branch, '--track', remote)) except: # this needs to be finer grained I think... raise FedpkgError('Could not create branch %s' % branch) else: -- cgit