Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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])
Ejemplo n.º 7
0
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])
Ejemplo n.º 8
0
def main(args):
    branch = get_current_branch_name()
    merge_with_base(branch, rebase=args.rebase)