Exemplo n.º 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)])
Exemplo n.º 2
0
def test_repo_git_url():
    eq_(M.repo_git_url('shire'), 'http://code.dapps.douban.com/shire.git')
    eq_(M.repo_git_url('user/shire'),
        'http://code.dapps.douban.com/user/shire.git')
    eq_(
        M.repo_git_url('user/shire', login_user='******'),
        'http://[email protected]/user/shire.git',
    )
Exemplo n.º 3
0
def add_remote(username):
    user_git_url = origin_git_url = None

    output = getoutput(['git', 'remote', '-v'])
    for line in output.splitlines():
        words = line.split()
        if words[0] == 'origin':
            origin_git_url = words[1]
        if words[0] == username:
            user_git_url = words[1]

    if not origin_git_url:
        raise Exception("No origin remote found, abort")

    repo = origin_git_url.rsplit('/', 1)[-1].rsplit('.', 1)[0]
    remote_name = username
    remote_url = repo_git_url('%s/%s' % (username, repo))

    if user_git_url:
        if user_git_url != remote_url:
            raise Exception("remote %s already exists, delete it first?")
        # already added
        return

    check_call(['git', 'remote', 'add', remote_name, remote_url])
Exemplo n.º 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)])
Exemplo n.º 5
0
def main(args):
    url = repo_git_url(args.repo, provider=args.provider)
    cmd = ['git', 'clone', url]

    if args.dir:
        cmd.append(args.dir)
        dir = args.dir
    else:
        dir = url.rsplit('/', 1)[-1].rpartition('.git')[0]

    check_call(cmd)

    with cd(dir):
        merge_config()

        # set upstream to origin to make other code commands work
        check_call(['git', 'remote', 'add', 'upstream', url])
Exemplo n.º 6
0
def main(args):
    url = repo_git_url(args.repo)
    cmd = ['git', 'clone', url]

    if args.dir:
        cmd.append(args.dir)
        dir = args.dir
    else:
        dir = url.rsplit('/', 1)[-1].rpartition('.git')[0]

    check_call(cmd)

    with cd(dir):
        merge_config()

        # set upstream to origin to make other code commands work
        check_call(['git', 'remote', 'add', 'upstream', url])
Exemplo n.º 7
0
def test_repo_git_url():
    eq_(M.repo_git_url('shire'), 'http://code.dapps.douban.com/shire.git')
    eq_(M.repo_git_url('user/shire'), 'http://code.dapps.douban.com/user/shire.git')
    eq_(M.repo_git_url('user/shire', login_user='******'),
        'http://[email protected]/user/shire.git')
Exemplo n.º 8
0
def test_repo_git_url():
    eq_(M.repo_git_url("shire"), "http://code.dapps.douban.com/shire.git")
    eq_(M.repo_git_url("user/shire"), "http://code.dapps.douban.com/user/shire.git")
    eq_(M.repo_git_url("user/shire", login_user="******"), "http://[email protected]/user/shire.git")