def test_reset_undo_local_changes(qisrc_action, git_server): git_server.create_repo("foo") manifest_url = git_server.manifest_url qisrc_action("init", manifest_url) git_worktree = TestGitWorkTree() foo_proj = git_worktree.get_git_project("foo") foo_git = TestGit(foo_proj.path) orig_gitinore = foo_git.read_file(".gitignore") foo_git.root.join(".gitignore").write("new line\n") qisrc_action("reset", "--force") assert foo_git.read_file(".gitignore") == orig_gitinore
def test_push_tags(git_server, tmpdir): foo_repo = git_server.create_repo("foo.git") foo_url = foo_repo.clone_url git_server.push_file("foo.git", "a.txt", "a") git_server.push_tag("foo.git", "v0.1") git_server.push_file("foo.git", "b.txt", "b") foo = tmpdir.mkdir("foo") foo_git = TestGit(foo.strpath) foo_git.clone(foo_url) assert foo_git.read_file("b.txt") == "b" foo_git.reset("--hard", "v0.1") #pylint:disable-msg=E1101 with pytest.raises(Exception): foo_git.read_file("b.txt") assert foo_git.read_file("a.txt") == "a"
def test_sync_reset(qisrc_action, git_server): git_server.create_repo("bar") git_server.create_repo("baz") qisrc_action("init", git_server.manifest_url) git_worktree = TestGitWorkTree() bar_proj = git_worktree.get_git_project("bar") baz_proj = git_worktree.get_git_project("baz") bar_git = TestGit(bar_proj.path) baz_git = TestGit(baz_proj.path) bar_git.checkout("-B", "devel") baz_git.commit_file("unrelated.txt", "unrelated\n") git_server.push_file("bar", "bar.txt", "this is bar\n") qisrc_action("sync", "--reset") assert bar_git.get_current_branch() == "master" assert bar_git.read_file("bar.txt") == "this is bar\n" # pylint: disable-msg=E1101 with pytest.raises(Exception): baz_git.read_file("unrelated.txt")
def test_sync_reset(qisrc_action, git_server): """ Test Sync Reset """ git_server.create_repo("bar") git_server.create_repo("baz") qisrc_action("init", git_server.manifest_url) git_worktree = TestGitWorkTree() bar_proj = git_worktree.get_git_project("bar") baz_proj = git_worktree.get_git_project("baz") bar_git = TestGit(bar_proj.path) baz_git = TestGit(baz_proj.path) bar_git.checkout("-B", "devel") baz_git.commit_file("unrelated.txt", "unrelated\n") git_server.push_file("bar", "bar.txt", "this is bar\n") qisrc_action("sync", "--reset") assert bar_git.get_current_branch() == "master" assert bar_git.read_file("bar.txt") == "this is bar\n" with pytest.raises(Exception): baz_git.read_file("unrelated.txt")
def test_sync_dash_g(qisrc_action, git_server): git_server.create_group("mygroup", ["a", "b"]) git_server.create_repo("other") git_server.push_file("other", "other.txt", "change 1") qisrc_action("init", git_server.manifest_url) git_server.push_file("other", "other.txt", "change 2") qisrc_action("sync", "--group", "mygroup") git_worktree = TestGitWorkTree() other_proj = git_worktree.get_git_project("other") other_git = TestGit(other_proj.path) assert other_git.read_file("other.txt") == "change 1"