diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-01-06 16:55:00 -0800 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-01-06 16:56:27 -0800 |
commit | a4f4ac3ad023be838f50b463b7ce785cf8e0de23 (patch) | |
tree | c51e9680daa5ac1abea0d422de2966ec04a49bab /src/fedpkg | |
parent | c0efdf758e3a96bf80e9711e12dd829763fca4fb (diff) | |
download | fedora-packager-a4f4ac3ad023be838f50b463b7ce785cf8e0de23.tar.gz fedora-packager-a4f4ac3ad023be838f50b463b7ce785cf8e0de23.tar.xz fedora-packager-a4f4ac3ad023be838f50b463b7ce785cf8e0de23.zip |
Finish up the clone function
More use of the git module and it's lambda for running arbitrary git
commands. There is no clone command within the git module.
Diffstat (limited to 'src/fedpkg')
-rw-r--r-- | src/fedpkg/__init__.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py index e296af6..85805ea 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -136,26 +136,40 @@ def clean(dry=False, useignore=True): log.error(error) return proc.returncode -def clone(module, user, branch=None): +def clone(module, user, path=os.getcwd(), branch=None): """Clone a repo, optionally check out a specific branch. module is the name of the module to clone + path is the basedir to perform the clone in + branch is the name of a branch to checkout instead of origin/master - gitargs is an optional list of arguments to git clone + Logs the output and returns the return code """ - # not implemented yet # construct the git url giturl = GITBASEURL % {'user': user, 'module': module} - cmd = ['git', 'clone'] - if branch: - cmd.extend(['--branch', branch]) - cmd.append(giturl) - print('Would have ran %s' % subprocess.list2cmdline(cmd)) - return + # Create the git object + mygit = git.Git(path) + # do the clone and capture the output + try: + if branch: + log.debug('Cloning %s with branch %s' % (giturl, branch)) + retcode, output, error = mygit.clone('--branch', branch, + giturl, + with_extended_output=True) + else: + log.debug('Cloning %s' % giturl) + retcode, output, error = mygit.clone(giturl, + with_extended_output=True) + except (git.GitCommandError, OSError), e: + raise FedpkgError('Could not clone %s: %s' % (giturl, e)) + log.info(output) + if error: + log.error(error) + return retcode def clone_with_dirs(module, user): """Clone a repo old style with subdirs for each branch. |