summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2011-02-17 18:25:51 -0700
committerJesse Keating <jkeating@redhat.com>2011-02-18 12:04:26 -0700
commit2e114216ebe376b6df03d3acc5c3cc2c7db876cf (patch)
tree136cf76eef8fa8a28cf51bb4687928fe3a243f7b
parent2748ee33fcd130c67c51d2fe06c05c35186c6e30 (diff)
downloadfedora-packager-2e114216ebe376b6df03d3acc5c3cc2c7db876cf.zip
fedora-packager-2e114216ebe376b6df03d3acc5c3cc2c7db876cf.tar.gz
fedora-packager-2e114216ebe376b6df03d3acc5c3cc2c7db876cf.tar.xz
Fix clone to work with old/new branch styles
This makes use of switch_branch to clone to a specific branch. This might have the side effect of "fixing" el5 where clone --branch is not supported by git.
-rw-r--r--src/pyfedpkg/__init__.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index 4816e6e..6a5f9da 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -425,21 +425,15 @@ def clone(module, user, path=None, branch=None, bare_dir=None):
else:
giturl = ANONGITURL % {'module': module}
- # do some branch name conversions
- if branch:
- remotere = 'f\d\d|el\d|olpc\d'
- if re.match(remotere, branch):
- branch = '%s/master' % branch
-
# Create the command
cmd = ['git', 'clone']
# do the clone
if branch and bare_dir:
- log.debug('Cloning %s bare with branch %s' % (giturl, branch))
- cmd.extend(['--branch', branch, '--bare', giturl, bare_dir])
+ raise FedpkgError('Cannot combine bare cloning with a branch')
elif branch:
- log.debug('Cloning %s with branch %s' % (giturl, branch))
- cmd.extend(['--branch', branch, giturl])
+ # For now we have to use switch branch
+ log.debug('Cloning %s without a checkout' % giturl)
+ cmd.extend(['-n', giturl])
elif bare_dir:
log.debug('Cloning %s bare' % giturl)
cmd.extend(['--bare', giturl, bare_dir])
@@ -448,6 +442,10 @@ def clone(module, user, path=None, branch=None, bare_dir=None):
cmd.extend([giturl])
_run_command(cmd)
+ # Check if we're supposed to work on a branch and if so, switch_branch
+ if branch:
+ switch_branch(branch, path=os.path.join(path, module))
+
# Set push.default to "tracking"
if not bare_dir:
repo = git.Repo(os.path.join(path, module))