示例#1
0
def test_fail_if_empty(tmpdir, test_git):
    foo_git = test_git(tmpdir.strpath)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    foo_git.set_tracking_branch("master", "origin")  # repo empty: fails
    (res, message) = foo_git.sync_branch(branch)
    assert res is None
    assert "no commits" in message
示例#2
0
def test_fast_forward(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master")
    foo_git.sync_branch(branch)
    assert foo_git.get_current_branch() == "master"
    assert foo_git.read_file("README") == "README on master"
示例#3
0
def test_clean_error_when_fetch_fails(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master")
    git_server.srv.remove()
    res, message = foo_git.sync_branch(branch)
    assert res is False
    assert "Fetch failed" in message
示例#4
0
def test_push_nonfastforward(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master v1")
    foo_git.sync_branch(branch)
    git_server.push_file("foo.git", "README", "README on master v2", fast_forward=False)
    (res, message) = foo_git.sync_branch(branch)
    assert res is True
    assert foo_git.read_file("README") == "README on master v2"
示例#5
0
def test_skip_if_unclean(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master")
    foo_git.sync_branch(branch)
    foo_git.root.join("README").write("changing README")
    (res, message) = foo_git.sync_branch(branch)
    assert foo_git.read_file("README") == "changing README"
    assert res is None
    assert "unstaged changes" in message
示例#6
0
def test_do_not_call_rebase_abort_when_reset_fails(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master")
    foo_path = foo_git.repo
    index_lock = os.path.join(foo_path, ".git", "index.lock")
    with open(index_lock, "w") as fp:
        fp.write("")
    (res, message) =  foo_git.sync_branch(branch)
    assert res is False
    assert "rebase --abort" not in message
示例#7
0
def test_rebase_by_default(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master")
    foo_git.commit_file("bar", "bar on master")
    foo_git.sync_branch(branch)
    assert foo_git.get_current_branch() == "master"
    assert foo_git.read_file("README") == "README on master"
    assert foo_git.read_file("bar") == "bar on master"
    rc, head = foo_git.call("show", "HEAD", raises=False)
    assert rc == 0
    assert "Merge" not in head
示例#8
0
def test_run_abort_when_rebase_fails(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master v1")
    foo_git.sync_branch(branch)
    git_server.push_file("foo.git", "README", "README on master v2", fast_forward=False)
    foo_git.commit_file("unrelated.txt", "Unrelated changes")

    (res, message) = foo_git.sync_branch(branch)
    assert res is False
    assert foo_git.get_current_branch() is not None
    assert "Rebase failed" in message
    assert foo_git.read_file("unrelated.txt") == "Unrelated changes"
    assert foo_git.read_file("README") == "README on master v1"
示例#9
0
def test_run_abort_when_rebase_fails(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    git_server.push_file("foo.git", "README", "README on master v1")
    foo_git.sync_branch(branch)
    git_server.push_file("foo.git", "README", "README on master v2",
                         fast_forward=False)
    foo_git.commit_file("unrelated.txt", "Unrelated changes")

    (res, message) = foo_git.sync_branch(branch)
    assert res is False
    assert foo_git.get_current_branch() is not None
    assert "Rebase failed" in message
    assert foo_git.read_file("unrelated.txt") == "Unrelated changes"
    assert foo_git.read_file("README") == "README on master v1"
示例#10
0
def test_up_to_date(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    foo_git.sync_branch(branch)
示例#11
0
def test_up_to_date(git_server, tmpdir, test_git):
    foo_git = create_foo(git_server, tmpdir, test_git)
    branch = Branch()
    branch.name = "master"
    branch.tracks = "origin"
    foo_git.sync_branch(branch)