本文整理汇总了Python中qisrc.git.commit函数的典型用法代码示例。如果您正苦于以下问题:Python commit函数的具体用法?Python commit怎么用?Python commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了commit函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_wrong_branch
def test_wrong_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)
git.update_branch("master", "origin")
readme = read_readme(bar_src)
self.assertEqual(readme, "bar\n")
# Checkout a 'next' branch
git.checkout("-b", "next")
with open(os.path.join(bar_src, "README"), "w") as fp:
fp.write("bar on next\n")
git.commit("-a", "-m", "README next")
# Push a new commit
push_readme_v2(self.tmp, "bar", "master")
# Update, check that master is up to date
err = git.update_branch("master", "origin")
self.assertFalse(err)
git.checkout("master")
readme = read_readme(bar_src)
self.assertEqual(readme, "bar v2 on master\n")
开发者ID:sanyaade-research-hub,项目名称:qibuild,代码行数:26,代码来源:test_git.py
示例2: test_conflict
def test_conflict(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)
# Create conflicting changes
write_readme(bar_src, "conflicting changes\n", append=True)
git.commit("-a", "-m", "conflicting changes")
push_readme_v2(self.tmp, "bar", "master")
# Updating branch should fail
err = git.update_branch("master", "origin")
self.assertTrue(err)
self.assertTrue("Merge conflict in README" in err, err)
# But we should be back at our previous commit
readme = read_readme(bar_src)
self.assertEqual(readme, "bar\nconflicting changes\n")
self.assertEqual(git.get_current_branch(), "master")
rebase_apply = os.path.join(git.repo, ".git", "rebase_apply")
self.assertFalse(os.path.exists(rebase_apply))
开发者ID:sanyaade-research-hub,项目名称:qibuild,代码行数:25,代码来源:test_git.py
示例3: push_file
def push_file(self, project, filename, contents,
branch="master", fast_forward=True,
message=None):
""" Push a new file with the given contents to the given project
It is assumed that the project has beed 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(filename)
if not message:
if to_write.check(file=True):
message = "Update %s" % filename
else:
message = "Add %s" % filename
repo_src.ensure(filename, file=True)
repo_src.join(filename).write(contents)
git.add(filename)
git.commit("--message", message)
if fast_forward:
git.push("origin", "%s:%s" % (branch, branch))
else:
git.push("origin", "--force", "%s:%s" % (branch, branch))
开发者ID:alkino,项目名称:qibuild,代码行数:28,代码来源:conftest.py
示例4: test_set_tracking_branch_existing_branch_tracking_other
def test_set_tracking_branch_existing_branch_tracking_other(tmpdir):
git = qisrc.git.Git(tmpdir.strpath)
git.init()
git.commit("-m", "empty", "--allow-empty")
git.set_tracking_branch("master", "origin")
ret = git.set_tracking_branch("master", "other")
assert ret is True
开发者ID:Phlogistique,项目名称:qibuild,代码行数:7,代码来源:test_git.py
示例5: 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
示例6: test_is_ff
def test_is_ff(tmpdir):
a_git = tmpdir.mkdir("a_git_project")
a_src = a_git.strpath
git = qisrc.git.Git(a_src)
git.init()
write_readme(a_src, "readme\n")
git.add(".")
git.commit("-m", "initial commit")
git.call("branch", "A")
write_readme(a_src, "readme2\n")
git.add(".")
git.commit("-m", "second commit")
git.call("branch", "B")
(ret, out) = git.call("show-ref", "--verify", "refs/heads/A", raises=False)
A_sha1 = out.split()[0]
(ret, out) = git.call("show-ref", "--verify", "refs/heads/B", raises=False)
B_sha1 = out.split()[0]
class Status:
pass
status = Status()
status.mess = ""
assert qisrc.git.is_ff(git, status, A_sha1, B_sha1) == True
assert qisrc.git.is_ff(git, status, B_sha1, A_sha1) == False
assert qisrc.git.is_ff(git, status, A_sha1, A_sha1) == True
开发者ID:bithium,项目名称:qibuild,代码行数:28,代码来源:test_git.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_relative_path
def test_relative_path(qisrc_action, tmpdir):
git = qisrc.git.Git(tmpdir.strpath)
git.init()
manifest = tmpdir.join("manifest.xml")
manifest.write("<manifest />")
git.add("manifest.xml")
git.commit("-m", "Initial commit")
qisrc_action("init", os.path.relpath(tmpdir.strpath))
assert os.path.isfile(os.path.join(".qi", "manifests", "default", "manifest.xml"))
开发者ID:Phlogistique,项目名称:qibuild,代码行数:9,代码来源:test_qisrc_init.py
示例9: push_manifest
def push_manifest(self, message, allow_empty=False):
""" Push new manifest.xml version """
manifest_repo = self.root.join("src", "manifest")
git = qisrc.git.Git(manifest_repo.strpath)
commit_args = ["--all", "--message", message]
if allow_empty:
commit_args.append("--allow-empty")
git.commit(*commit_args)
git.checkout("--force", "-B", self.manifest_branch)
git.push("origin", "%s:%s" % (self.manifest_branch, self.manifest_branch))
开发者ID:Giessen,项目名称:qibuild,代码行数:10,代码来源:conftest.py
示例10: 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
示例11: manifest_repo
def manifest_repo(self):
# the repo is always in manifests/default for backward-compatible reasons
res = os.path.join(self.git_worktree.root, ".qi", "manifests", "default")
if not os.path.exists(res):
qisys.sh.mkdir(res, recursive=True)
git = qisrc.git.Git(res)
git.init()
manifest_xml = os.path.join(res, "manifest.xml")
with open(manifest_xml, "w") as fp:
fp.write("<manifest />")
git.add(".")
git.commit("-m", "initial commit")
return res
开发者ID:Grimy,项目名称:qibuild,代码行数:13,代码来源:sync.py
示例12: add_qibuild_test_project
def add_qibuild_test_project(self, src):
project_name = src + ".git"
repo_src = self._create_repo(project_name , src=src, review=False)
this_dir = os.path.dirname(__file__)
src_path = os.path.join(this_dir, "..", "..", "qibuild", "test", "projects", src)
qisys.sh.copy_git_src(src_path, repo_src)
git = TestGit(repo_src)
git.add(".")
git.commit("--message", "Add sources from qibuild test project %s" % src)
git.push("origin", "master:master")
self.manifest.add_repo(project_name, src, ["origin"])
repo = self.manifest.get_repo(project_name)
self.push_manifest("Add qibuild test project: %s" % src)
开发者ID:alkino,项目名称:qibuild,代码行数:13,代码来源:conftest.py
示例13: test_gen_scm_info
def test_gen_scm_info(build_worktree, tmpdir):
build_worktree.add_test_project("world")
hello_proj = build_worktree.add_test_project("hello")
git = qisrc.git.Git(hello_proj.path)
git.init()
git.add(".")
git.commit("--message", "initial commit")
rc, sha1 = git.call("rev-parse", "HEAD", raises=False)
package_xml = tmpdir.join("package.xml").strpath
hello_proj.gen_package_xml(package_xml)
tree = qisys.qixml.read(package_xml)
scm_elem = tree.find("scm")
git_elem = scm_elem.find("git")
assert git_elem.get("revision") == sha1
开发者ID:Grimy,项目名称:qibuild,代码行数:14,代码来源:test_project.py
示例14: push_file
def push_file(tmp, git_path, filename, contents, branch="master"):
""" Push a file to the given url. Assumes the repository
has been created with :py:func:`create_git_repo` with the same
path
"""
tmp_src = os.path.join(tmp, "src", git_path)
tmp_srv = os.path.join(tmp, "srv", git_path + ".git")
git = qisrc.git.Git(tmp_src)
if branch in git.get_local_branches():
git.checkout("-f", branch)
else:
git.checkout("-b", branch)
dirname = os.path.dirname(filename)
qibuild.sh.mkdir(os.path.join(tmp_src, dirname), recursive=True)
with open(os.path.join(tmp_src, filename), "w") as fp:
fp.write(contents)
git.add(filename)
git.commit("-m", "added %s" % filename)
git.push(tmp_srv, "%s:%s" % (branch, branch))
开发者ID:sanyaade-research-hub,项目名称:qibuild,代码行数:20,代码来源:test_git.py
示例15: test_wrong_branch_with_conflicts
def test_wrong_branch_with_conflicts(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)
# Create conflicting changes
write_readme(bar_src, "conflicting changes\n", append=True)
git.commit("-a", "-m", "conflicting changes")
push_readme_v2(self.tmp, "bar", "master")
# Checkout an other branch
git.checkout("-b", "next")
# Try to update master while being on an other branch:
err = git.update_branch("master", "origin")
self.assertTrue(err)
self.assertTrue("Merge is not fast-forward" in err)
开发者ID:sanyaade-research-hub,项目名称:qibuild,代码行数:20,代码来源:test_git.py
示例16: main
def main():
parser = argparse.ArgumentParser()
parser.add_argument("version")
args = parser.parse_args()
version = args.version
this_dir = os.path.dirname(__file__)
qibuild_root = os.path.join(this_dir, "..")
git = qisrc.git.Git(qibuild_root)
ok, message = git.require_clean_worktree()
if not ok:
raise Exception(message)
for filename in FILES_TO_PATCH:
full_path = os.path.join(qibuild_root, filename)
fix_version_for_file(full_path, "next", version)
git.commit("--all", "-m", "qibuild %s" % version)
git.call("tag", "v" + version)
for filename in FILES_TO_PATCH:
full_path = os.path.join(qibuild_root, filename)
fix_version_for_file(filename, version, "next")
git.commit("--all", "-m", "start next development")
print "All OK feel free to push"
开发者ID:cgestes,项目名称:qibuild,代码行数:21,代码来源:release.py
注:本文中的qisrc.git.commit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论