本文整理汇总了Python中qisrc.git.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: push_submodule
def push_submodule(self, project, submodule_url, destination_dir,
branch="master", fast_forward=True,
message=None):
"""
Push a submodule to the given project.
It is assumed that the project has been created.
"""
src = project.replace(".git", "")
repo_src = self.src.join(src)
git = qisrc.git.Git(repo_src.strpath)
if git.get_current_branch() != branch:
git.checkout("--force", "-B", branch)
if not fast_forward:
git.reset("--hard", "HEAD~1")
to_write = repo_src.join(destination_dir)
if to_write.exists():
raise RuntimeError("path %s already exists" % destination_dir)
if not message:
message = "Add submodule %s" % destination_dir
git.call("submodule", "add", submodule_url, destination_dir)
git.add(destination_dir)
git.commit("--message", message)
if fast_forward:
git.push("origin", "%s:%s" % (branch, branch))
else:
git.push("origin", "--force", "%s:%s" % (branch, branch))
开发者ID:aldebaran,项目名称:qibuild,代码行数:29,代码来源:conftest.py
示例2: test_switching_from_fixed_ref_to_branch_local_changes
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"
开发者ID:aldebaran,项目名称:qibuild,代码行数:28,代码来源:test_qisrc_sync.py
示例3: diff_worktree
def diff_worktree(git_worktree, git_projects, branch, cmd=None):
""" Run `git <cmd> local_branch..remote_branch` for every project
"""
if not cmd:
cmd = ["log"]
remote_projects = git_worktree.get_projects_on_branch(branch)
for git_project in git_projects:
remote_project = remote_projects.get(git_project.src)
if not remote_project:
continue
git = qisrc.git.Git(git_project.path)
local_branch = git.get_current_branch()
remote_branch = remote_project.default_branch.name
remote_ref = "%s/%s" % (remote_project.default_remote.name, remote_branch)
rc, out = git.call("merge-base", local_branch, remote_ref, raises=False)
if rc != 0:
continue
merge_base = out.strip()
full_cmd = cmd + ["%s..%s" % (merge_base, local_branch)]
color = ui.config_color(sys.stdout)
if color:
full_cmd.append("--color=always")
rc, out = git.call(*full_cmd, raises=False)
if rc != 0:
continue
if not out:
continue
ui.info(ui.bold, git_project.src)
ui.info(ui.bold, "-" * len(git_project.src))
ui.info(out)
ui.info()
开发者ID:Grimy,项目名称:qibuild,代码行数:33,代码来源:diff.py
示例4: stat_tracking_remote
def stat_tracking_remote(git, branch, tracking):
""" Check if branch is ahead and / or behind tracking. """
if branch is None or tracking is None:
return 0, 0
_, local_ref = git.call("rev-parse", branch, raises=False)
_, remote_ref = git.call("rev-parse", tracking, raises=False)
return stat_ahead_behind(git, local_ref, remote_ref)
开发者ID:aldebaran,项目名称:qibuild,代码行数:7,代码来源:status.py
示例5: clever_reset_ref
def clever_reset_ref(git_project, ref, raises=True):
""" Resets only if needed, fetches only if needed """
try:
remote_name = git_project.default_remote.name
except AttributeError:
error_msg = "Project {} has no default remote, defaulting to origin"
ui.error(error_msg.format(git_project.name))
remote_name = "origin"
git = qisrc.git.Git(git_project.path)
# Deals with "refs/" prefixed ref first
if ref.startswith("refs/"):
return _reset_hard_to_refs_prefixed_ref(git, remote_name, ref, raises=raises)
# Else, ref format is a local name (branch or tag)
# Check if this ref exists and if we are already in the expected state
rc, ref_sha1 = git.call("rev-parse", ref, "--", raises=False)
if rc != 0:
# Maybe this is a newly pushed tag, try to fetch:
git.fetch(remote_name)
rc, ref_sha1 = git.call("rev-parse", ref, "--", raises=False)
if rc != 0:
return False, "Could not parse %s as a valid ref" % ref
_, actual_sha1 = git.call("rev-parse", "HEAD", raises=False)
if actual_sha1 == ref_sha1: # Nothing to do
return None if raises else True, ""
# Reset to the ref local name
return _reset_hard_to_local_refs_name(git, remote_name, ref, raises=raises)
开发者ID:aldebaran,项目名称:qibuild,代码行数:26,代码来源:reset.py
示例6: push_branch
def push_branch(self, project, branch):
""" push branch on project """
src = project.replace(".git", "")
repo_src = self.src.join(src)
git = qisrc.git.Git(repo_src.strpath)
# create the branch
git.call("branch", branch)
git.push("origin", branch)
开发者ID:aldebaran,项目名称:qibuild,代码行数:8,代码来源:conftest.py
示例7: delete_file
def delete_file(self, project, filename):
""" Delete a file from the repository """
src = project.replace(".git", "")
repo_src = self.src.join(src)
git = qisrc.git.Git(repo_src.strpath)
git.call("rm", filename)
git.commit("--message", "remove %s" % filename)
git.push("origin", "master:master")
开发者ID:alkino,项目名称:qibuild,代码行数:8,代码来源:conftest.py
示例8: _test_switching_to_fixed_ref_happy
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
开发者ID:aldebaran,项目名称:qibuild,代码行数:55,代码来源:test_qisrc_sync.py
示例9: test_git_get_local_branches
def test_git_get_local_branches(tmpdir):
tmpdir = tmpdir.strpath
git = qisrc.git.Git(tmpdir)
# pylint: disable-msg=E1101
with pytest.raises(Exception):
git.get_local_branches()
write_readme(tmpdir, "readme\n")
git.call("init")
git.call("add", ".")
git.commit("-m", "initial commit")
assert git.get_local_branches() == ["master"]
git.checkout("-b", "devel")
assert git.get_local_branches() == ["devel", "master"]
开发者ID:sanyaade-research-hub,项目名称:qibuild,代码行数:13,代码来源:test_git.py
示例10: stat_tracking_remote
def stat_tracking_remote(git, branch, tracking):
"""Check if branch is ahead and / or behind tracking."""
behind = 0
ahead = 0
(ret, out) = git.call("rev-list", "--left-right",
"%s..%s" % (tracking, branch), raises=False)
if ret == 0:
ahead = len(out.split())
(ret, out) = git.call("rev-list", "--left-right",
"%s..%s" % (branch, tracking), raises=False)
if ret == 0:
behind = len(out.split())
return (ahead, behind)
开发者ID:Grimy,项目名称:qibuild,代码行数:13,代码来源:status.py
示例11: test_fixed_ref_behind
def test_fixed_ref_behind(qisrc_action, git_server, record_messages):
""" Test Fixed Ref Behind """
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.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 = qisrc.git.Git(foo_proj.path)
git.call("reset", "--hard", "HEAD~1")
qisrc_action("status")
assert record_messages.find("fixed ref v0.1 -1")
开发者ID:aldebaran,项目名称:qibuild,代码行数:13,代码来源:test_qisrc_status.py
示例12: test_new_project_under_review
def test_new_project_under_review(tmpdir, git_server):
foo_repo = git_server.create_repo("foo.git", review=False)
assert foo_repo.review is False
git_server.use_review("foo.git")
foo_repo = git_server.get_repo("foo.git")
assert foo_repo.review is True
assert foo_repo.review_remote.name == "gerrit"
git = qisrc.git.Git(tmpdir.strpath)
rc, out = git.call("ls-remote", foo_repo.clone_url, raises=False)
assert rc == 0
git = qisrc.git.Git(tmpdir.strpath)
rc, out = git.call("ls-remote", foo_repo.review_remote.url, raises=False)
assert rc == 0
开发者ID:cameronyoyos,项目名称:qibuild,代码行数:13,代码来源:test_fixture.py
示例13: push_tag
def push_tag(self, project, tag, branch="master", fast_forward=True):
""" push tag on project """
src = project.replace(".git", "")
repo_src = self.src.join(src)
git = qisrc.git.Git(repo_src.strpath)
if git.get_current_branch() != branch:
git.checkout("--force", "-B", branch)
if not fast_forward:
git.reset("--hard", "HEAD~1")
# tag the branch
git.call("tag", tag)
if fast_forward:
git.push("origin", tag)
else:
git.push("origin", "--force", tag)
开发者ID:aldebaran,项目名称:qibuild,代码行数:15,代码来源:conftest.py
示例14: test_create_review_repos
def test_create_review_repos(tmpdir, git_server):
foo_repo = git_server.create_repo("foo", review=True)
assert foo_repo.review_remote.name == "gerrit"
assert foo_repo.default_remote.name == "origin"
git = qisrc.git.Git(tmpdir.strpath)
rc, out = git.call("ls-remote", foo_repo.clone_url, raises=False)
assert rc == 0
开发者ID:cameronyoyos,项目名称:qibuild,代码行数:7,代码来源:test_fixture.py
示例15: test_qisrc_checkout_with_branch_to_ref
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
开发者ID:aldebaran,项目名称:qibuild,代码行数:27,代码来源:test_qisrc_checkout.py
示例16: test_create_empty_repo
def test_create_empty_repo(tmpdir, git_server):
""" Test Create Empty Repo """
foo_repo = git_server.create_repo("foo", empty=True)
git = qisrc.git.Git(tmpdir.strpath)
rc, out = git.call("ls-remote", foo_repo.clone_url, raises=False)
assert rc == 0
assert not out
开发者ID:aldebaran,项目名称:qibuild,代码行数:7,代码来源:test_fixture.py
示例17: stat_ahead_behind
def stat_ahead_behind(git, local_ref, remote_ref):
"""
Returns a tuple (ahead, behind) describing how far
from the remote ref the local ref is.
"""
behind = 0
ahead = 0
(ret, out) = git.call("rev-list", "--left-right",
"%s..%s" % (remote_ref, local_ref), raises=False)
if ret == 0:
ahead = len(out.split())
(ret, out) = git.call("rev-list", "--left-right",
"%s..%s" % (local_ref, remote_ref), raises=False)
if ret == 0:
behind = len(out.split())
return ahead, behind
开发者ID:aldebaran,项目名称:qibuild,代码行数:16,代码来源:status.py
示例18: __str__
def __str__(self):
""" String Representation of the Toochain """
git_path = qisys.sh.get_share_path("qi", "toolchains", self.name + ".git")
sha1 = None
if os.path.exists(git_path):
git = qisrc.git.Git(git_path)
_, sha1 = git.call("rev-parse", "HEAD", raises=False)
res = "Toolchain %s\n" % self.name
if self.feed_url:
res += "Using feed from %s" % self.feed_url
if self.feed_name:
res += " (feeds/%s.xml)" % self.feed_name
if self.feed_branch:
res += " on %s" % self.feed_branch
if sha1:
res += " - %s" % sha1[:8]
res += "\n"
else:
res += "No feed\n"
if self.packages:
res += " Packages:\n"
else:
res += "No packages\n"
sorted_packages = sorted(self.packages)
for package in sorted_packages:
res += ui.indent(package.name, 2)
if package.version:
res += " " + package.version
res += "\n"
if package.path:
res += ui.indent("in " + package.path, 3) + "\n"
return res
开发者ID:aldebaran,项目名称:qibuild,代码行数:32,代码来源:toolchain.py
示例19: test_with_git
def test_with_git(qisrc_action):
qisrc_action("create", "foo", "--git")
worktree = TestWorkTree()
foo_proj = worktree.get_project("foo")
git = qisrc.git.Git(foo_proj.path)
ret, out = git.call("show", "HEAD", raises=False)
assert ret == 0
assert ".gitignore" in out
开发者ID:Phlogistique,项目名称:qibuild,代码行数:8,代码来源:test_qisrc_create.py
示例20: snapshot
def snapshot(self):
""" Return a :py:class`.Snapshot` of the current worktree state
"""
snapshot = qisrc.snapshot.Snapshot()
snapshot.manifest = self.manifest
git = qisrc.git.Git(self._syncer.manifest_repo)
rc, out = git.call("rev-parse", "HEAD", raises=False)
snapshot.manifest.ref = out
for git_project in self.git_projects:
src = git_project.src
git = qisrc.git.Git(git_project.path)
rc, out = git.call("rev-parse", "HEAD", raises=False)
if rc != 0:
ui.error("git rev-parse HEAD failed for", src)
continue
snapshot.refs[src] = out.strip()
return snapshot
开发者ID:Phlogistique,项目名称:qibuild,代码行数:18,代码来源:worktree.py
注:本文中的qisrc.git.call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论