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

Function test_amend_commit_metadata

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

Source from the content-addressed store, hash-verified

154
155
156def test_amend_commit_metadata(barerepo: Repository) -> None:
157 repo = barerepo
158 commit = repo[COMMIT_SHA_TO_AMEND]
159 assert isinstance(commit, Commit)
160 assert commit.id == repo.head.target
161
162 encoding = 'iso-8859-1'
163 amended_message = 'Amended commit message.\n\nMessage with non-ascii chars: ééé.\n'
164 amended_author = Signature(
165 'Jane Author', 'jane@example.com', 12345, 0, encoding=encoding
166 )
167 amended_committer = Signature(
168 'John Committer', 'john@example.com', 12346, 0, encoding=encoding
169 )
170
171 amended_oid = repo.amend_commit(
172 commit,
173 'HEAD',
174 message=amended_message,
175 author=amended_author,
176 committer=amended_committer,
177 encoding=encoding,
178 )
179 amended_commit = repo[amended_oid]
180 assert isinstance(amended_commit, Commit)
181
182 assert repo.head.target == amended_oid
183 assert ObjectType.COMMIT.value == amended_commit.type
184 assert amended_committer == amended_commit.committer
185 assert amended_author == amended_commit.author
186 assert amended_message.encode(encoding) == amended_commit.raw_message
187 assert commit.author != amended_commit.author
188 assert commit.committer != amended_commit.committer
189 assert commit.tree == amended_commit.tree # we didn't touch the tree
190
191
192def test_amend_commit_tree(barerepo: Repository) -> None:

Callers

nothing calls this directly

Calls 1

amend_commitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…