MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_new_commit

Function test_new_commit

test/test_commit.py:75–105  ·  view source on GitHub ↗
(barerepo: Repository)

Source from the content-addressed store, hash-verified

73
74
75def test_new_commit(barerepo: Repository) -> None:
76 repo = barerepo
77 message = 'New commit.\n\nMessage with non-ascii chars: ééé.\n'
78 committer = Signature('John Doe', 'jdoe@example.com', 12346, 0)
79 author = Signature(
80 'J. David Ibáñez', 'jdavid@example.com', 12345, 0, encoding='utf-8'
81 )
82 tree = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12'
83 tree_prefix = tree[:5]
84 too_short_prefix = tree[:3]
85
86 parents = [COMMIT_SHA[:5]]
87 with pytest.raises(ValueError):
88 repo.create_commit(None, author, committer, message, too_short_prefix, parents)
89
90 sha = repo.create_commit(None, author, committer, message, tree_prefix, parents)
91 commit = repo[sha]
92 assert isinstance(commit, Commit)
93
94 assert ObjectType.COMMIT.value == commit.type
95 assert '98286caaab3f1fde5bf52c8369b2b0423bad743b' == commit.id
96 assert commit.message_encoding is None
97 assert message == commit.message
98 assert 12346 == commit.commit_time
99 assert committer == commit.committer
100 assert author == commit.author
101 assert tree == commit.tree.id
102 assert Oid(hex=tree) == commit.tree_id
103 assert 1 == len(commit.parents)
104 assert COMMIT_SHA == commit.parents[0].id
105 assert Oid(hex=COMMIT_SHA) == commit.parent_ids[0]
106
107
108def test_new_commit_encoding(barerepo: Repository) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…