本文整理汇总了Python中qisrc.test.conftest.TestGitWorkTree.get_git_project方法的典型用法代码示例。如果您正苦于以下问题:Python TestGitWorkTree.get_git_project方法的具体用法?Python TestGitWorkTree.get_git_project怎么用?Python TestGitWorkTree.get_git_project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qisrc.test.conftest.TestGitWorkTree
的用法示例。
在下文中一共展示了TestGitWorkTree.get_git_project方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_qisrc_checkout_with_branch_to_ref
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_qisrc_checkout_with_branch_to_ref(qisrc_action, git_server):
""" Test QiSrc Checkout With Branch to Ref """
manifest_url = git_server.manifest_url
git_server.create_repo("foo.git")
git_server.create_repo("bar.git")
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")
git_server.push_tag("bar.git", "v0.2")
git_server.push_file("bar.git", "c.txt", "b")
qisrc_action("init", manifest_url)
git_server.switch_manifest_branch("devel")
git_server.set_fixed_ref("foo.git", "v0.1")
git_server.set_fixed_ref("bar.git", "v0.2")
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
git = TestGit(foo_proj.path)
assert git.get_current_branch() == "master"
qisrc_action("checkout", "devel")
_, sha1 = git.call("rev-parse", "HEAD", raises=False)
expected = git.get_ref_sha1("refs/tags/v0.1")
assert sha1 == expected
bar_proj = git_worktree.get_git_project("bar")
bar_git = qisrc.git.Git(bar_proj.path)
_, sha1 = bar_git.call("rev-parse", "HEAD", raises=False)
expected = bar_git.get_ref_sha1("refs/tags/v0.2")
assert sha1 == expected
示例2: test_uses_build_deps_by_default
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_uses_build_deps_by_default(qisrc_action, git_server):
git_server.add_qibuild_test_project("world")
git_server.add_qibuild_test_project("hello")
git_server.create_repo("foo.git")
qisrc_action("init", git_server.manifest_url)
# Crete some changes in foo and world
git_server.push_file("foo.git", "foo.txt", "unrelated changes")
git_server.push_file("world.git", "world.txt", "dependency has been updated")
# Sync hello
qisrc_action.chdir("hello")
qisrc_action("sync")
qisrc_action.chdir(qisrc_action.root)
git_worktree = TestGitWorkTree()
# foo is not a dep, should not have changed:
foo_proj = git_worktree.get_git_project("foo")
foo_txt = os.path.join(foo_proj.path, "foo.txt")
assert not os.path.exists(foo_txt)
# World is a dep of hello:
world_proj = git_worktree.get_git_project("world")
world_txt = os.path.join(world_proj.path, "world.txt")
assert os.path.exists(world_txt)
示例3: _test_switching_to_fixed_ref_happy
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def _test_switching_to_fixed_ref_happy(qisrc_action, git_server, record_messages, tag_ref_to_test, branch_ref_to_test):
""" Test Switching To Fixed Ref Happy """
git_server.create_repo("foo.git")
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")
git_server.push_branch("foo.git", "feature/b")
git_server.push_file("foo.git", "c.txt", "c")
qisrc_action("init", git_server.manifest_url)
# Check for fixed_ref tag
git_server.set_fixed_ref("foo.git", tag_ref_to_test)
qisrc_action("sync")
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
git = qisrc.git.Git(foo_proj.path)
_, sha1 = git.call("rev-parse", "HEAD", raises=False)
expected = git.get_ref_sha1("refs/tags/v0.1")
assert sha1 == expected
# qisrc.reset.clever_reset_ref should tell where is the HEAD after reset
record_messages.reset()
qisrc_action("sync")
assert record_messages.find("HEAD is now at")
assert record_messages.find("Add a.txt")
_, status_output = git.status(raises=False)
assert "HEAD" in status_output
assert "detached" in status_output
# If branch ref name is local, makesure it exists on local copy, then go back to master
if branch_ref_to_test == "feature/b":
git.checkout("feature/b", raises=False)
git.checkout("master", raises=False)
# Check for fixed_ref branch
git_server.set_fixed_ref("foo.git", branch_ref_to_test)
qisrc_action("sync")
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
git = qisrc.git.Git(foo_proj.path)
_, sha1 = git.call("rev-parse", "HEAD", raises=False)
expected = git.get_ref_sha1("refs/remotes/origin/feature/b")
assert sha1 == expected
# qisrc.reset.clever_reset_ref should tell where is the HEAD after reset
record_messages.reset()
qisrc_action("sync")
assert record_messages.find("HEAD is now at")
assert record_messages.find("Add b.txt")
_, status_output = git.status(raises=False)
# FIXME: when using ref long name branch (refs/xxx), if we come from a tag, we stay in a detached head,
# and we should be in an attached head state to be consistent with the ref short name branc behaviour
# That's not an issue for now as users reference short name in manifest, but it will be cleaner to be consistent...
if not branch_ref_to_test.startswith("refs/"):
assert "HEAD" not in status_output
assert "detached" not in status_output
else:
# Remove these assert when dealing with behaviour consistency mentionned above
assert "HEAD" in status_output
assert "detached" in status_output
示例4: test_moving_repos_sync_action
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_moving_repos_sync_action(git_worktree, git_server, qisrc_action):
git_server.create_repo("lib/foo.git")
manifest_url = git_server.manifest_url
git_worktree.configure_manifest("default", manifest_url)
git_server.move_repo("lib/foo.git", "lib/bar")
qisrc_action("sync")
git_worktree = TestGitWorkTree()
assert not git_worktree.get_git_project("lib/foo")
assert git_worktree.get_git_project("lib/bar")
# Sync twice just to test that nothing happens
qisrc_action("sync")
示例5: test_wrong_branch
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_wrong_branch(qisrc_action, git_server, record_messages):
""" Test Wrong Branch """
git_server.create_repo("foo.git")
git_server.create_repo("bar.git")
qisrc_action("init", git_server.manifest_url)
git_worktree = TestGitWorkTree()
foo1 = git_worktree.get_git_project("foo")
_bar1 = git_worktree.get_git_project("bar")
foo_git = qisrc.git.Git(foo1.path)
foo_git.checkout("-B", "devel")
qisrc_action("status")
assert record_messages.find("Some projects are not on the expected branch")
assert record_messages.find(r"\* foo\s+devel\s+master")
示例6: test_checkout_happy
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_checkout_happy(qisrc_action, git_server):
manifest_url = git_server.manifest_url
git_server.create_repo("foo.git")
git_server.create_repo("bar.git")
qisrc_action("init", manifest_url)
git_server.switch_manifest_branch("devel")
git_server.change_branch("foo.git", "devel")
qisrc_action("checkout", "devel")
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
foo_git = qisrc.git.Git(foo_proj.path)
assert foo_git.get_current_branch() == "devel"
bar_proj = git_worktree.get_git_project("bar")
bar_git = qisrc.git.Git(bar_proj.path)
assert bar_git.get_current_branch() == "master"
示例7: test_clone_new_repos
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_clone_new_repos(qisrc_action, git_server):
git_server.create_repo("foo.git")
qisrc_action("init", git_server.manifest_url)
git_server.create_repo("bar.git")
qisrc_action("sync")
git_worktree = TestGitWorkTree()
assert git_worktree.get_git_project("bar")
示例8: test_sync_branch_devel
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_sync_branch_devel(qisrc_action, git_server, test_git):
# This tests the case where everything goes smoothly
git_server.create_repo("foo.git")
qisrc_action("init", git_server.manifest_url)
git_server.push_file("foo.git", "foo.txt", "a super change")
git_server.push_file("foo.git", "bar.txt", "a super bugfix")
git_worktree = TestGitWorkTree()
foo = git_worktree.get_git_project("foo")
test_git = TestGit(foo.path)
test_git.call("checkout", "-b", "devel")
test_git.commit_file("developing.txt", "like a boss")
git_server.push_file("foo.git", "foobar.txt", "some other change")
git_server.push_file("foo.git", "bigchange.txt", "some huge change")
qisrc_action("sync", "--rebase-devel")
test_git.call("checkout", "master")
# Check that master is fast-forwarded
bigchange_txt = os.path.join(foo.path, "bigchange.txt")
assert os.path.exists(bigchange_txt)
# Check rebase is done smoothly
test_git.call("checkout", "devel")
test_git.call("rebase", "master")
assert os.path.exists(bigchange_txt)
developing_txt = os.path.join(foo.path, "developing.txt")
assert os.path.exists(developing_txt)
示例9: test_check_configures_review
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_check_configures_review(qisrc_action, git_server):
# Get a correct xml file from the server:
manifest_url = git_server.manifest_url
qisrc_action("init", manifest_url)
git_server.create_repo("foo.git")
git_server._create_repo("foo.git", review=True)
# Create a foo repo, but without code review set
foo_proj = qisrc_action.create_git_project("foo")
assert not foo_proj.review
# Edit the manifest.xml to set code review for foo
srv_xml = git_server.src.join("manifest", "manifest.xml")
manifest = qisrc.manifest.Manifest(srv_xml.strpath)
editable_path = qisrc_action.tmpdir.join("manifest.xml")
manifest.manifest_xml = editable_path.strpath
foo_repo = manifest.get_repo("foo.git")
foo_repo.remote_names = ["origin", "gerrit"]
manifest.dump()
# Run qisrc check-manifest
qisrc_action("check-manifest", editable_path.strpath)
# Code review should be now set:
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
assert foo_proj.review
示例10: test_check
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_check(qisrc_action, git_server):
# Get a correct xml file from the server:
manifest_url = git_server.manifest_url
git_server.create_repo("foo.git")
qisrc_action("init", manifest_url)
# copy it to an other place, make a mistake, and run --check:
srv_xml = git_server.src.join("manifest", "manifest.xml")
manifest = qisrc.manifest.Manifest(srv_xml.strpath)
editable_path = qisrc_action.tmpdir.join("manifest.xml")
manifest.manifest_xml = editable_path.strpath
manifest.add_repo("doestnotexists.git", "nowhere", ["origin"])
manifest.dump()
rc = qisrc_action("check-manifest", editable_path.strpath,
retcode=True)
assert rc != 0
# running qisrc sync should still work:
qisrc_action("sync")
# this time create a correct xml and re-run --check:
git_server.create_repo("bar.git")
manifest = qisrc.manifest.Manifest(srv_xml.strpath)
editable_path = qisrc_action.tmpdir.join("manifest.xml")
manifest.manifest_xml = editable_path.strpath
manifest.dump()
qisrc_action("check-manifest", editable_path.strpath)
git_worktree = TestGitWorkTree()
assert git_worktree.get_git_project("bar")
# running qisrc sync just to be sure:
qisrc_action("sync")
示例11: setup_test
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def setup_test():
build_worktree = TestBuildWorkTree()
foo = build_worktree.create_project("foo")
world = build_worktree.create_project("world")
hello = build_worktree.create_project("hello", build_depends=["world"])
git = qisrc.git.Git(foo.path)
git.init()
git = qisrc.git.Git(world.path)
git.init()
git = qisrc.git.Git(hello.path)
git.init()
git_worktree = TestGitWorkTree()
foo = git_worktree.get_git_project("foo")
hello = git_worktree.get_git_project("hello")
world = git_worktree.get_git_project("world")
return (foo, hello, world)
示例12: test_creates_required_subdirs
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_creates_required_subdirs(qisrc_action, git_server):
""" Test Create Required SubDirs """
git_server.create_repo("foo/bar.git")
qisrc_action("init", git_server.manifest_url)
qisrc_action("sync")
git_worktree = TestGitWorkTree()
assert git_worktree.get_git_project("foo/bar")
示例13: test_switching_from_fixed_ref_to_branch_local_changes
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_switching_from_fixed_ref_to_branch_local_changes(qisrc_action, git_server, record_messages):
""" Test Swithcing From Fixed Ref To Branch Local Changes """
git_server.create_repo("foo.git")
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")
git_server.push_tag("foo.git", "v0.2")
git_server.push_file("foo.git", "c.txt", "c")
git_server.set_fixed_ref("foo.git", "v0.1")
qisrc_action("init", git_server.manifest_url)
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
git = TestGit(foo_proj.path)
git.write_file("a.txt", "unstaged changes")
git_server.set_branch("foo.git", "master")
record_messages.reset()
rc = qisrc_action("sync", retcode=True)
# ERROR message must be displayed to warn user
assert rc != 0
assert record_messages.find("unstaged changes")
_, sha1 = git.call("rev-parse", "HEAD", raises=False)
expected = git.get_ref_sha1("refs/tags/v0.1")
# git repo unchanged
assert sha1 == expected
git.call("reset", "--hard")
qisrc_action("sync", retcode=True)
# if modification is revert sync must be successful
assert git.get_current_branch() == "master"
示例14: test_using_checkout_after_no_review
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_using_checkout_after_no_review(qisrc_action, git_server):
git_server.create_repo("foo", review=True)
qisrc_action("init", git_server.manifest_url, "--no-review")
git_server.switch_manifest_branch("devel")
qisrc_action("checkout", "devel")
git_worktree = TestGitWorkTree()
foo = git_worktree.get_git_project("foo")
assert not foo.review
示例15: test_retcode_when_skipping
# 需要导入模块: from qisrc.test.conftest import TestGitWorkTree [as 别名]
# 或者: from qisrc.test.conftest.TestGitWorkTree import get_git_project [as 别名]
def test_retcode_when_skipping(qisrc_action, git_server):
git_server.create_repo("bar")
qisrc_action("init", git_server.manifest_url)
git_worktree = TestGitWorkTree()
bar_proj = git_worktree.get_git_project("bar")
git = TestGit(bar_proj.path)
git.checkout("-b", "devel")
rc = qisrc_action("sync", retcode=True)
assert rc != 0