| |
@@ -3277,6 +3277,20 @@
|
| |
|
| |
self.second_commit = repo.revparse_single("HEAD")
|
| |
|
| |
+ # Add empty commit
|
| |
+ repo.create_commit(
|
| |
+ "refs/heads/master", # the name of the reference to update
|
| |
+ author,
|
| |
+ committer,
|
| |
+ "Empty commit",
|
| |
+ # binary string representing the tree object ID
|
| |
+ tree,
|
| |
+ # list of binary strings representing parents of the new commit
|
| |
+ [self.second_commit.oid.hex],
|
| |
+ )
|
| |
+
|
| |
+ self.third_commit = repo.revparse_single("HEAD")
|
| |
+
|
| |
def test_commit_to_patch_first_commit(self):
|
| |
""" Test the commit_to_patch function of pagure.lib.git. """
|
| |
repo = pygit2.init_repository(self.gitrepo)
|
| |
@@ -3622,6 +3636,24 @@
|
| |
|
| |
self.assertEqual(output, exp)
|
| |
|
| |
+ def test_commit_to_patch_empty_commit(self):
|
| |
+ """ Test the commit_to_path function of pagure.lib.git. """
|
| |
+ repo = pygit2.init_repository(self.gitrepo)
|
| |
+
|
| |
+ patch = pagure.lib.git.commit_to_patch(repo, self.third_commit)
|
| |
+ exp = ""
|
| |
+ self.assertEqual(patch, exp)
|
| |
+
|
| |
+ def test_commit_to_patch_empty_commit_diff(self):
|
| |
+ """ Test the commit_to_patch function of pagure.lib.git. """
|
| |
+ repo = pygit2.init_repository(self.gitrepo)
|
| |
+
|
| |
+ patch = pagure.lib.git.commit_to_patch(
|
| |
+ repo, self.third_commit, diff_view=True
|
| |
+ )
|
| |
+ exp = ""
|
| |
+ self.assertEqual(patch, exp)
|
| |
+
|
| |
|
| |
if __name__ == "__main__":
|
| |
unittest.main(verbosity=2)
|
| |