From e11fb1cca1de4f09f30ed142fea06427f2293661 Mon Sep 17 00:00:00 2001 From: Léon Keijser Date: Thu, 15 Jul 2010 09:39:47 +0200 Subject: Added new command 'switch-branch' for working with branches. --- src/pyfedpkg/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/pyfedpkg/__init__.py') diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index 53b7e3e..799ae97 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -251,6 +251,28 @@ def clean(dry=False, useignore=True): log.error(error) return proc.returncode +def switch_branch(branch=None, list=None): + """Work with different branches. + + branch is the name of the branch to switch to + + Logs output and returns nothing. + """ + if list: + cmd = ['git', 'branch'] + print "Listing branches" + cmd.extend(['-a']) + _run_command(cmd) + else: + cmd = ['git', 'checkout'] + cmd.extend([branch]) + log.debug('Switching to branch %s' % branch) + try: + _run_command(cmd) + except FedpkgError: + sys.exit(1) + return + def clone(module, user, path=os.getcwd(), branch=None, bare_dir=None): """Clone a repo, optionally check out a specific branch. -- cgit