def main(args): branches = args.branches if not branches: branches = [get_current_branch_name()] assert 'master' not in branches, "Cannot terminate master branch!" for br in branches: try: end_branch(br, args.force) except subprocess.CalledProcessError as e: print(e) log_error("Fail to delete branch %s." % br)
def submit_new_pullreq(remote='upstream', remote_branch=None, no_merge=False): branch = get_current_branch_name() if branch == 'master': print_log('Pull request should never be from master') return 1 if not no_merge: rebase = not branch_is_published_already(branch) merge_with_base(branch, rebase=rebase, remote=remote, remote_branch=remote_branch) push_to_my_fork(branch) send_pullreq(branch, remote=remote, remote_branch=remote_branch)
def main(args): branch = get_current_branch_name() if args.action == 'pull': merge_with_base(branch, rebase=args.rebase, remote_branch=args.base, remote=args.remote) else: sync_to_remote(branch, remote=args.remote, remote_branch=args.base, force=args.force)
def end_branch(branch, force): if branch == get_current_branch_name(): check_call(['git', 'checkout', 'master']) if force: check_call(['git', 'branch', '-D', branch]) else: try: check_call(['git', 'branch', '-d', branch]) except subprocess.CalledProcessError: log_error("Failed to delete branch %s because it is not fully " "merged (may cause commits loss)." % branch) answer = ask("Do you want to force to delete it even so? (y/N) ", pattern=r'[nNyY].*', default='n') if answer[0] in 'yY': check_call(['git', 'branch', '-D', branch]) else: raise if does_branch_exist_on_origin(branch): check_call(['git', 'push', 'origin', ':%s' % branch])
def main(args): branch = get_current_branch_name() merge_with_base(branch, rebase=args.rebase)