diff options
Diffstat (limited to 'src/pyfedpkg')
-rw-r--r-- | src/pyfedpkg/__init__.py | 22 |
1 files changed, 22 insertions, 0 deletions
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. |