-
-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix incorrect empty message commit serialization
* Fixes incorrect signature verification for commits with an empty message, as encoded by CGit (#1429)
- Loading branch information
Showing
3 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,74 @@ def test_verify(self): | |
tag = self.repo[b"refs/tags/verifyme"] | ||
self.assertNotEqual(tag.signature, None) | ||
tag.verify() | ||
|
||
|
||
@skipIf( | ||
platform.python_implementation() == "PyPy" or sys.platform == "win32", | ||
"gpgme not easily available or supported on Windows and PyPy", | ||
) | ||
class CommitCreateSignTestCase(PorcelainGpgTestCase, CompatTestCase): | ||
def test_sign(self): | ||
# Test that dulwich signatures can be verified by CGit | ||
cfg = self.repo.get_config() | ||
cfg.set(("user",), "signingKey", PorcelainGpgTestCase.DEFAULT_KEY_ID) | ||
self.import_default_key() | ||
|
||
porcelain.commit( | ||
self.repo.path, | ||
b"messy message messiah", | ||
b"foo <[email protected]>", | ||
signoff=True, | ||
) | ||
|
||
run_git_or_fail( | ||
[f"--git-dir={self.repo.controldir()}", "verify-commit", "-v", "HEAD"], | ||
env={"GNUPGHOME": os.environ["GNUPGHOME"]}, | ||
) | ||
|
||
def test_verify(self): | ||
# Test that CGit signatures can be verified by dulwich | ||
self.import_default_key() | ||
|
||
run_git_or_fail( | ||
[ | ||
f"--git-dir={self.repo.controldir()}", | ||
"commit", | ||
"--allow-empty", | ||
"-S" + PorcelainGpgTestCase.DEFAULT_KEY_ID, | ||
"-m", | ||
"foo", | ||
], | ||
env={ | ||
"GNUPGHOME": os.environ["GNUPGHOME"], | ||
"GIT_COMMITTER_NAME": "Joe Example", | ||
"GIT_COMMITTER_EMAIL": "[email protected]", | ||
}, | ||
) | ||
commit = self.repo[b"HEAD"] | ||
self.assertNotEqual(commit.gpgsig, None) | ||
commit.verify() | ||
|
||
def test_verify_with_empty_message(self): | ||
# Test that CGit signatures can be verified by dulwich | ||
self.import_default_key() | ||
|
||
run_git_or_fail( | ||
[ | ||
f"--git-dir={self.repo.controldir()}", | ||
"commit", | ||
"--allow-empty", | ||
"-S" + PorcelainGpgTestCase.DEFAULT_KEY_ID, | ||
"--allow-empty-message", | ||
"-m", | ||
"", | ||
], | ||
env={ | ||
"GNUPGHOME": os.environ["GNUPGHOME"], | ||
"GIT_COMMITTER_NAME": "Joe Example", | ||
"GIT_COMMITTER_EMAIL": "[email protected]", | ||
}, | ||
) | ||
commit = self.repo[b"HEAD"] | ||
self.assertNotEqual(commit.gpgsig, None) | ||
commit.verify() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1066,7 +1066,7 @@ def test_serialize_none_message(self): | |
b"type blob\n" | ||
b"tag 0.1\n" | ||
b"tagger Jelmer Vernooij <[email protected]> " | ||
b"423423423 +0000\n" | ||
b"423423423 +0000\n\n" | ||
), | ||
x.as_raw_string(), | ||
) | ||
|