Skip to content

Commit 62ecd6c

Browse files
committed
Fix trailing newline handling and typo on test code.
1 parent 8065d2a commit 62ecd6c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

git/objects/commit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def _serialize(self, stream):
403403

404404
if self.gpgsig:
405405
write("gpgsig")
406-
for sigline in self.gpgsig.split("\n"):
406+
for sigline in self.gpgsig.rstrip("\n").split("\n"):
407407
write(" "+sigline+"\n")
408408

409409
write("\n")
@@ -458,7 +458,7 @@ def _deserialize(self, stream):
458458
is_next_header = True
459459
break
460460
sig += sigbuf[1:]
461-
self.gpgsig = sig
461+
self.gpgsig = sig.rstrip("\n")
462462
if is_next_header:
463463
continue
464464
buf = readline().strip()

git/test/objects/test_commit.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,11 @@ def test_gpgsig(self):
298298
BX/otlTa8pNE3fWYBxURvfHnMY4i3HQT7Bc1QjImAhMnyo2vJk4ORBJIZ1FTNIhJ
299299
JzJMZDRLQLFvnzqZuCjE
300300
=przd
301-
-----END PGP SIGNATURE-----
302-
"""
301+
-----END PGP SIGNATURE-----"""
303302
assert cmt.gpgsig == fixture_sig
304303

305304
cmt.gpgsig = "<test\ndummy\nsig>"
306-
assert cmt.gpgsig != sig
305+
assert cmt.gpgsig != fixture_sig
307306

308307
cstream = StringIO()
309308
cmt._serialize(cstream)
@@ -312,7 +311,7 @@ def test_gpgsig(self):
312311
cstream.seek(0)
313312
cmt.gpgsig = None
314313
cmt._deserialize(cstream)
315-
assert cmt.gpgsig == "<test\ndummy\nsig>\n"
314+
assert cmt.gpgsig == "<test\ndummy\nsig>"
316315

317316
cmt.gpgsig = None
318317
cstream = StringIO()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy