本文整理汇总了Python中repoman.git.repository.Repository.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.commit方法的具体用法?Python Repository.commit怎么用?Python Repository.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repoman.git.repository.Repository
的用法示例。
在下文中一共展示了Repository.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_commit_custom_parent
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_commit_custom_parent(self):
gitrepo = Repository(self.main_repo)
gitrepo.update('master')
c1 = gitrepo.commit('A commit', allow_empty=True)
c2 = gitrepo.commit('Other commit', allow_empty=True)
gitrepo.commit('Commit with custom parent', allow_empty=True,
custom_parent=c1.hash)
self.assertEquals(
[p.hash for p in gitrepo.parents()],
[c2.hash, c1.hash])
示例2: test_commit_commits_but_with_removed_files
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_commit_commits_but_with_removed_files(self):
file_name = "test1.txt"
file_path = os.path.join(self.main_repo, file_name)
commit_msg = "Test message"
gitrepo = Repository(self.main_repo)
gitrepo.update('master')
os.remove(file_path)
git = GitCmd(self.main_repo)
gitrepo.commit(commit_msg)
git('reset', hard=True)
self.assertTrue(os.path.exists(file_path))
示例3: test_commit_commits_but_with_removed_files
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_commit_commits_but_with_removed_files(self):
file_name = "test1.txt"
file_path = os.path.join(self.main_repo, file_name)
commit_msg = "Test message"
gitrepo = Repository(self.main_repo)
gitrepo.update('master')
os.remove(file_path)
gitrepo.commit(commit_msg)
repo = pygit2.Repository(self.main_repo)
repo.reset(repo.head.target.hex, pygit2.GIT_RESET_HARD)
repo.checkout_head(strategy=(pygit2.GIT_CHECKOUT_FORCE |
pygit2.GIT_CHECKOUT_REMOVE_UNTRACKED))
self.assertTrue(os.path.exists(file_path))
示例4: test_no_notes_go_fine
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_no_notes_go_fine(self):
gitrepo = Repository(self.cloned_from_repo)
gitrepo.update('master')
changeset = gitrepo.commit('A new commit!', allow_empty=True)
notes = gitrepo.get_changeset_notes(changeset.hash)
self.assertEqual([], notes)
notes = gitrepo.get_changeset_notes()
self.assertEqual([], notes)
示例5: test_commit_commits_all
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_commit_commits_all(self):
file_name = "test1.txt"
file_path = os.path.join(self.main_repo, file_name)
expected_content = "changed content"
commit_msg = "Test message"
with open(file_path, "w+") as file:
file.write(expected_content)
gitrepo = Repository(self.main_repo)
gitrepo.commit(commit_msg)
with open(file_path, "w+") as fd:
fd.write('content changed again')
git = GitCmd(self.main_repo)
git('reset', hard=True)
self.assertTrue(os.path.exists(file_path))
with open(file_path) as fd:
self.assertEquals(expected_content, fd.read())
示例6: test_commit
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_commit(self):
file_name = "test_file"
file_path = os.path.join(self.main_repo, file_name)
with open(file_path, "a") as file:
file.write('test content')
commit_msg = "Test message"
git = GitCmd(self.main_repo)
initial_len = len(list(git('log', 'HEAD', pretty='oneline', _iter=True)))
gitrepo = Repository(self.main_repo)
gitrepo.add(file_name)
commit = gitrepo.commit(commit_msg)
final_len = len(list(git('log', 'HEAD', pretty='oneline', _iter=True)))
self.assertEquals(final_len, initial_len + 1)
self.assertEquals(git('log', '-1', pretty='%B'), commit_msg)
self.assertEquals(commit.desc, commit_msg)
self.assertIsNone(gitrepo.commit(commit_msg))
示例7: test_commit
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_commit(self):
file_name = "test_file"
file_path = os.path.join(self.main_repo, file_name)
with open(file_path, "a") as file:
file.write('test content')
commit_msg = "Test message"
repo = pygit2.Repository(self.main_repo)
initial_len = len(list(repo.walk(repo.head.target,
pygit2.GIT_SORT_TOPOLOGICAL)))
gitrepo = Repository(self.main_repo)
gitrepo.add(file_name)
commit = gitrepo.commit(commit_msg)
final_len = len(list(repo.walk(repo.head.target,
pygit2.GIT_SORT_TOPOLOGICAL)))
self.assertEquals(final_len, initial_len + 1)
self.assertEquals(repo.head.get_object().message, commit_msg)
self.assertEquals(commit.desc, commit_msg)
self.assertIsNone(gitrepo.commit(commit_msg))
示例8: test_commit_commits_all
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_commit_commits_all(self):
file_name = "test1.txt"
file_path = os.path.join(self.main_repo, file_name)
expected_content = "changed content"
commit_msg = "Test message"
with open(file_path, "w+") as file:
file.write(expected_content)
gitrepo = Repository(self.main_repo)
gitrepo.commit(commit_msg)
with open(file_path, "w+") as fd:
fd.write('content changed again')
repo = pygit2.Repository(self.main_repo)
repo.reset(repo.head.target.hex, pygit2.GIT_RESET_HARD)
repo.checkout_head(strategy=(pygit2.GIT_CHECKOUT_FORCE |
pygit2.GIT_CHECKOUT_REMOVE_UNTRACKED))
self.assertTrue(os.path.exists(file_path))
with open(file_path) as fd:
self.assertEquals(expected_content, fd.read())
示例9: test_push_all_with_reference_and_revision
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_push_all_with_reference_and_revision(self):
git1 = GitCmd(self.main_repo_bare)
git2 = GitCmd(self.cloned_from_repo)
repo2 = Repository(self.cloned_from_repo)
repo2.commit('A commit', allow_empty=True)
cs = repo2.commit('A second commit', allow_empty=True)
repo2.tag('unqualified', revision=cs.hash)
notes_ref = repo2.append_note('some note dude', cs.hash)
repo2.push(self.main_repo, self.main_repo_bare, rev=cs.hash, ref_name='master')
notes_ref_repo1, commit_ref_repo1 = git1('notes', 'list').split()
notes_ref_repo2, commit_ref_repo2 = git2('notes', 'list').split()
self.assertEqual(commit_ref_repo1, commit_ref_repo2)
self.assertEqual(notes_ref_repo1, notes_ref_repo2)
self.assertEqual(notes_ref, notes_ref_repo1)
changesets1 = list(git1('log', 'unqualified', '--', pretty='oneline', _iter=True))
changesets2 = list(git2('log', 'unqualified', '--', pretty='oneline', _iter=True))
self.assertEquals(changesets1, changesets2)
示例10: test_push_to_unqualified_destination
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_push_to_unqualified_destination(self):
git1 = GitCmd(self.main_repo_bare)
git2 = GitCmd(self.cloned_from_repo)
repo2 = Repository(self.cloned_from_repo)
cs = repo2.commit('A commit', allow_empty=True)
# Pushing a revision to a reference name that doesn't exist is
# considered a push to an unqualified destination
repo2.push(self.main_repo, self.main_repo_bare, rev=cs.hash, ref_name='unqualified')
changesets1 = list(git1('log', 'unqualified', pretty='oneline', _iter=True))
changesets2 = list(git2('log', cs.hash, pretty='oneline', _iter=True))
self.assertEquals(changesets1, changesets2)
示例11: test_append_get_and_has_notes
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_append_get_and_has_notes(self):
gitrepo = Repository(self.cloned_from_repo)
gitrepo.update('master')
changeset = gitrepo.commit('A new commit!', allow_empty=True)
gitrepo.append_note('Hello note 1', revision=changeset.hash)
gitrepo.append_note('Goodbye note 2')
notes = gitrepo.get_changeset_notes(changeset.hash)
self.assertEqual(['Hello note 1', 'Goodbye note 2'], notes)
self.assertTrue(gitrepo.has_note('Hello note 1'))
self.assertTrue(gitrepo.has_note('Goodbye note 2', changeset.hash))
self.assertFalse(gitrepo.has_note(''))
self.assertFalse(gitrepo.has_note('\n'))
示例12: test_push_only_notes
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_push_only_notes(self):
git1 = GitCmd(self.main_repo_bare)
git2 = GitCmd(self.cloned_from_repo)
repo2 = Repository(self.cloned_from_repo)
cs = repo2.commit('A commit', allow_empty=True)
repo2.push(self.main_repo, self.main_repo_bare, rev=cs.hash, ref_name='master')
notes_ref = repo2.append_note('some note dude', cs.hash)
repo2.push(self.main_repo, self.main_repo_bare, ref_name='refs/notes/*')
notes_ref_repo1, commit_ref_repo1 = git1('notes', 'list').split()
notes_ref_repo2, commit_ref_repo2 = git2('notes', 'list').split()
self.assertEqual(commit_ref_repo1, commit_ref_repo2)
self.assertEqual(notes_ref_repo1, notes_ref_repo2)
self.assertEqual(notes_ref, notes_ref_repo1)
示例13: test_merge_with_conflict
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_merge_with_conflict(self):
gitrepo = Repository(self.cloned_from_repo)
# Checkout
gitrepo.update('newbranch')
file_to_conflict_name = 'test1.txt'
file_to_conflict = os.path.join(self.cloned_from_repo,
file_to_conflict_name)
with open(file_to_conflict, "w") as file:
file_content = "Absurd content"
file.write(file_content)
gitrepo.add(file_to_conflict_name)
conflict_cs = gitrepo.commit("Provoking conflict")
gitrepo.update('master')
try:
gitrepo.merge(other_rev=conflict_cs)
self.fail()
except MergeConflictError as exp:
self.assertTrue('Conflicts found: merging test1.txt failed' in exp)
示例14: test_merge_fastforward_no_ff
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_merge_fastforward_no_ff(self):
repo = pygit2.Repository(self.cloned_from_repo)
gitrepo = Repository(self.cloned_from_repo)
gitrepo.update('master')
gitrepo.branch('ff-branch')
ff_file_name = 'ff-file.txt'
ff_file = os.path.join(self.cloned_from_repo, ff_file_name)
with open(ff_file, "w") as file:
file_content = "Absurd content"
file.write(file_content)
gitrepo.add(ff_file_name)
ff_head = gitrepo.commit(message="commit ff file")
gitrepo.update('master')
cs = gitrepo.merge(other_rev=ff_head, other_branch_name='test')
self.assertEquals(len(repo.head.get_object().parents), 2)
self.assertEquals(repo.head.get_object().hex, cs.hash)
# We want a commit in fastforward merges, hashes must be different
self.assertNotEquals(ff_head.hash, cs.hash)
self.assertTrue(os.path.isfile(ff_file))
示例15: test_merge_fastforward_no_ff
# 需要导入模块: from repoman.git.repository import Repository [as 别名]
# 或者: from repoman.git.repository.Repository import commit [as 别名]
def test_merge_fastforward_no_ff(self):
git = GitCmd(self.cloned_from_repo)
gitrepo = Repository(self.cloned_from_repo)
gitrepo.update('master')
gitrepo.branch('ff-branch')
ff_file_name = 'ff-file.txt'
ff_file = os.path.join(self.cloned_from_repo, ff_file_name)
with open(ff_file, "w") as file:
file_content = "Absurd content"
file.write(file_content)
gitrepo.add(ff_file_name)
ff_head = gitrepo.commit(message="commit ff file")
gitrepo.update('master')
cs = gitrepo.merge(other_rev=ff_head, other_branch_name='test')
self.assertEquals(len(git('log', '-1', pretty='%P').split()), 2)
self.assertEquals(git('rev-parse', 'HEAD'), cs.hash)
# We want a commit in fastforward merges, hashes must be different
self.assertNotEquals(ff_head.hash, cs.hash)
self.assertTrue(os.path.isfile(ff_file))