From 2e114216ebe376b6df03d3acc5c3cc2c7db876cf Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Thu, 17 Feb 2011 18:25:51 -0700 Subject: 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. --- src/pyfedpkg/__init__.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/pyfedpkg/__init__.py') 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)) -- cgit