Skip to content

GPG signature support on commit object. #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix trailing newline handling and typo on test code.
  • Loading branch information
sugi committed Oct 7, 2013
commit 62ecd6c66a84144632b045696326af503ee8cd4e
4 changes: 2 additions & 2 deletions git/objects/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def _serialize(self, stream):

if self.gpgsig:
write("gpgsig")
for sigline in self.gpgsig.split("\n"):
for sigline in self.gpgsig.rstrip("\n").split("\n"):
write(" "+sigline+"\n")

write("\n")
Expand Down Expand Up @@ -458,7 +458,7 @@ def _deserialize(self, stream):
is_next_header = True
break
sig += sigbuf[1:]
self.gpgsig = sig
self.gpgsig = sig.rstrip("\n")
if is_next_header:
continue
buf = readline().strip()
Expand Down
7 changes: 3 additions & 4 deletions git/test/objects/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,11 @@ def test_gpgsig(self):
BX/otlTa8pNE3fWYBxURvfHnMY4i3HQT7Bc1QjImAhMnyo2vJk4ORBJIZ1FTNIhJ
JzJMZDRLQLFvnzqZuCjE
=przd
-----END PGP SIGNATURE-----
"""
-----END PGP SIGNATURE-----"""
assert cmt.gpgsig == fixture_sig

cmt.gpgsig = "<test\ndummy\nsig>"
assert cmt.gpgsig != sig
assert cmt.gpgsig != fixture_sig

cstream = StringIO()
cmt._serialize(cstream)
Expand All @@ -312,7 +311,7 @@ def test_gpgsig(self):
cstream.seek(0)
cmt.gpgsig = None
cmt._deserialize(cstream)
assert cmt.gpgsig == "<test\ndummy\nsig>\n"
assert cmt.gpgsig == "<test\ndummy\nsig>"

cmt.gpgsig = None
cstream = StringIO()
Expand Down