def start(branch, directory=""): branches = Git.branches() if branch in branches: raise ValueError(_ERROR % (branch, " ".join(branches))) directory = clone(directory) Call.call_raw("git checkout -b " + branch, cwd=directory) banner("Checked out new branch", branch)
def swap(a, b): missing = set((a, b)) - set(Git.branches()) if missing: raise Exception("Non-existent branch%s: %s" % ("" if len(missing) == 1 else "es", " ".join(missing))) temp = a + "-" + b rename(a, temp) rename(b, a) rename(temp, b)
def rename(old, new=None): if not new: old, new = Git.branch(), old if new in Git.branches(): if not ARGS.force: raise Exception('The branch %s already exists.' % new) Delete.delete(new) Fresh.fresh(new, old) Delete.delete(old)