Ejemplo n.º 1
0
def merge_and_push(from_branch, to_branch):
    check_call(['git', 'fetch', 'upstream'])
    local_branch = 'merge/{0}-to-{1}'.format(from_branch, to_branch)
    existing_branches = get_branches()
    answer = 'd'
    if local_branch in existing_branches:
        answer = input(
            "Branch {0} exists.  Should I (d)estroy it and "
            "re-merge from scratch, or re(u)se it in case you "
            "were resolving merge conflicts just now? (D/u) ".format(
                local_branch),
            pattern=r'[dDuU]',
            default='d').lower()[0]

    if answer == 'd':
        check_call([
            'git', 'checkout', '-B', local_branch,
            'upstream/{0}'.format(to_branch)
        ])

    else:
        check_call(['git', 'checkout', local_branch])

    check_call(['git', 'merge', 'upstream/{0}'.format(from_branch)])
    check_call(
        ['git', 'push', 'upstream', '{0}:{1}'.format(local_branch, to_branch)])
    check_call(['git', 'checkout', 'master'])
    check_call(['git', 'branch', '-d', local_branch])
Ejemplo n.º 2
0
def test_get_branches_should_return_a_list_of_branch_names():
    with mkdtemp(cd=True):
        check_call(['git', 'init'])
        open('test', 'w').close()
        check_call(['git', 'add', 'test'])
        check_call(['git', 'commit', '-m', 'test'], env=env)

        branches = M.get_branches()
    eq_(branches, ['master'])
Ejemplo n.º 3
0
def test_get_branches_should_return_a_list_of_branch_names():
    with mkdtemp(cd=True):
        check_call(['git', 'init'])
        open('test', 'w').close()
        check_call(['git', 'add', 'test'])
        check_call(['git', 'commit', '-m', 'test'], env=env)

        branches = M.get_branches()
    eq_(branches, ['master'])
Ejemplo n.º 4
0
def test_get_branches_should_return_a_list_of_branch_names():
    with mkdtemp(cd=True):
        check_call(["git", "init"])
        open("test", "w").close()
        check_call(["git", "add", "test"])
        check_call(["git", "commit", "-m", "test"], env=env)

        branches = M.get_branches()
    eq_(branches, ["master"])
Ejemplo n.º 5
0
def start(branch, remote='upstream', fetch_args=[], base_ref='upstream/master'):
    existing_branches = get_branches()
    if branch in existing_branches:
        answer = ask("Branch %s exists, (s)witch to it or re(c)reate "
                     "it?  (S/c) " % branch, pattern=r'[sScC]',
                     default='s')
        answer = answer.lower()[0]

        if answer == 's':
            check_call(['git', 'checkout', branch])
            return

        elif answer == 'c':
            end_branch(branch, force=True)

    check_call(['git', 'fetch', remote] + fetch_args)
    check_call(['git', 'checkout', '-b', branch, '--no-track', base_ref])
Ejemplo n.º 6
0
def start(branch, remote='upstream', checkout_branch='master', fetch_args=[]):
    existing_branches = get_branches()
    if branch in existing_branches:
        answer = ask("Branch %s exists, (s)witch to it or re(c)reate "
                     "it?  (S/c) " % branch,
                     pattern=r'[sScC]',
                     default='s')
        answer = answer.lower()[0]

        if answer == 's':
            check_call(['git', 'checkout', branch])
            return

        elif answer == 'c':
            end_branch(branch, force=True)

    base_ref = '%s/%s' % (remote, checkout_branch)
    check_call(['git', 'fetch', remote] + fetch_args)
    check_call(['git', 'checkout', '-b', branch, '--no-track', base_ref])
Ejemplo n.º 7
0
def merge_and_push(from_branch, to_branch):
    check_call(["git", "fetch", "upstream"])
    local_branch = "merge/{0}-to-{1}".format(from_branch, to_branch)
    existing_branches = get_branches()
    answer = "d"
    if local_branch in existing_branches:
        answer = input(
            "Branch {0} exists.  Should I (d)estroy it and "
            "re-merge from scratch, or re(u)se it in case you "
            "were resolving merge conflicts just now? (D/u) ".format(local_branch),
            pattern=r"[dDuU]",
            default="d",
        ).lower()[0]

    if answer == "d":
        check_call(["git", "checkout", "-B", local_branch, "upstream/{0}".format(to_branch)])

    else:
        check_call(["git", "checkout", local_branch])

    check_call(["git", "merge", "upstream/{0}".format(from_branch)])
    check_call(["git", "push", "upstream", "{0}:{1}".format(local_branch, to_branch)])
    check_call(["git", "checkout", "master"])
    check_call(["git", "branch", "-d", local_branch])
Ejemplo n.º 8
0
def merge_and_push(from_branch, to_branch):
    check_call(['git', 'fetch', 'upstream'])
    local_branch = 'merge/{0}-to-{1}'.format(from_branch, to_branch)
    existing_branches = get_branches()
    answer = 'd'
    if local_branch in existing_branches:
        answer = ask("Branch {0} exists.  Should I (d)estroy it and "
                     "re-merge from scratch, or re(u)se it in case you "
                     "were resolving merge conflicts just now? (D/u) "
                     .format(local_branch), pattern=r'[dDuU]',
                     default='d').lower()[0]

    if answer == 'd':
        check_call(['git', 'checkout',
                    '-B', local_branch, 'upstream/{0}'.format(to_branch)])

    else:
        check_call(['git', 'checkout', local_branch])

    check_call(['git', 'merge', 'upstream/{0}'.format(from_branch)])
    check_call(['git', 'push', 'upstream',
                '{0}:{1}'.format(local_branch, to_branch)])
    check_call(['git', 'checkout', 'master'])
    check_call(['git', 'branch', '-d', local_branch])
Ejemplo n.º 9
0
def does_branch_exist_on_origin(branch):
    branches = get_branches(include_remotes=True)
    return 'remotes/origin/{0}'.format(branch) in branches
Ejemplo n.º 10
0
def does_branch_exist_on_origin(branch):
    branches = get_branches(include_remotes=True)
    return 'remotes/origin/{0}'.format(branch) in branches