示例#1
0
def main(args):
    name = args.upstream

    code_username = ''
    if not args.origin:
        code_username = get_code_username()
        if not code_username:
            log_error('origin not specified')
            return 1
        repo_name = name.split('/')[-1]
        args.origin = '%s/%s' % (code_username, repo_name)

    if not args.dir:
        args.dir = name.rsplit('/')[-1]
        print_log("Destination dir is not specified, will use {}".format(
            args.dir))

    check_call([
        'git',
        'clone',
        repo_git_url(args.origin,
                     login_user=code_username,
                     provider=args.provider),
        args.dir,
    ])
    with cd(args.dir):
        merge_config()
        check_call(['git', 'remote', 'add', 'upstream', repo_git_url(name)])
示例#2
0
文件: end.py 项目: hongqn/codecli
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)
示例#3
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)
示例#4
0
def main(args):
    name = args.upstream

    code_username = ''
    if not args.origin:
        code_username = get_code_username()
        if not code_username:
            log_error('origin not specified')
            return 1
        args.origin = '%s/%s' % (code_username, name)

    if not args.dir:
        args.dir = name.rsplit('/')[-1]
        print_log("Destination dir is not specified, will use {}".format(args.dir))

    check_call(['git', 'clone', repo_git_url(args.origin, login_user=code_username), args.dir])
    with cd(args.dir):
        merge_config()
        check_call(['git', 'remote', 'add', 'upstream', repo_git_url(name)])
示例#5
0
文件: end.py 项目: hongqn/codecli
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])
示例#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])