(barerepo: Repository)
| 154 | |
| 155 | |
| 156 | def 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 | |
| 192 | def test_amend_commit_tree(barerepo: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…