def test_pushing_files(tmpdir, git_server): """ Test Pushing Fles """ _origin_url = git_server.manifest.get_remote("origin").url foo_repo = git_server.create_repo("foo.git") foo_url = foo_repo.clone_url foo_clone = tmpdir.mkdir("foo") git = qisrc.git.Git(foo_clone.strpath) git.clone(foo_url) git_server.push_file("foo.git", "README", "This is foo\n") git.pull() assert foo_clone.join("README").read() == "This is foo\n"
def test_get_current_branch(self): bar_url = create_git_repo(self.tmp, "bar") work = os.path.join(self.tmp, "work") qibuild.sh.mkdir(work) bar_src = os.path.join(work, "bar") git = qisrc.git.Git(bar_src) git.clone(bar_url) self.assertEqual(git.get_current_branch(), "master") push_readme_v2(self.tmp, "bar", "master") git.pull() self.assertEqual(git.get_current_branch(), "master") git.checkout("-f", "HEAD~1") self.assertEqual(git.get_current_branch(), None)
def test_set_tracking_branch(tmpdir): tmpdir = tmpdir.strpath bar_url = create_git_repo(tmpdir, "bar") work = os.path.join(tmpdir, "work") bar_src = os.path.join(work, "bar") git = qisrc.git.Git(bar_src) git.clone(bar_url) push_file(tmpdir, "bar", "README", "README on release", branch="release") push_file(tmpdir, "bar", "README", "README on master", branch="master") git.update_branch("master", "origin") git.set_tracking_branch("release", "origin") err = git.update_branch("release", "origin") assert not err # This should work out of the box git.pull() git.checkout("release") git.pull()
def test_set_remote(self): bar_url = create_git_repo(self.tmp, "bar", with_release_branch=True) work = os.path.join(self.tmp, "work") qibuild.sh.mkdir(work) bar_src = os.path.join(work, "bar") git = qisrc.git.Git(bar_src) git.clone(bar_url, "-o", "foo") # Must work: git.pull() git.set_remote("origin", bar_url) # Must NOT work: out, err_ = git.pull("origin", raises=False) self.assertFalse(out == 0) # Must work git.set_tracking_branch("master", "origin") git.pull() readme = read_readme(bar_src) self.assertEqual(readme, "bar\n") git.set_tracking_branch("stable", "origin", remote_branch="release-1.12") git.checkout("stable") git.pull() readme = read_readme(bar_src) self.assertEqual(readme, "bar on release-1.12\n")