Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b789ebc

Browse filesBrowse files
committed
Fix for parsing GPG signatures related to #57 but applied to 0.3.
Without it, the following error happens: LookupError: unknown encoding: -----BEGIN PGP SIGNATURE----- I Couldn't cherry pick. Git went spaz. The original author is @sugi and the commit is from sugi/GitPython: 8065d2a
1 parent 0b820e6 commit b789ebc
Copy full SHA for b789ebc

1 file changed

+31-9Lines changed: 31 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/objects/commit.py‎

Copy file name to clipboardExpand all lines: git/objects/commit.py
+31-9Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
5757
__slots__ = ("tree",
5858
"author", "authored_date", "author_tz_offset",
5959
"committer", "committed_date", "committer_tz_offset",
60-
"message", "parents", "encoding")
60+
"message", "parents", "encoding", "gpgsig")
6161
_id_attribute_ = "binsha"
6262

6363
def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
6464
committer=None, committed_date=None, committer_tz_offset=None,
65-
message=None, parents=None, encoding=None):
65+
message=None, parents=None, encoding=None, gpgsig=None):
6666
"""Instantiate a new Commit. All keyword arguments taking None as default will
6767
be implicitly set on first query.
6868
@@ -120,6 +120,7 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
120120
self.parents = parents
121121
if encoding is not None:
122122
self.encoding = encoding
123+
self.gpgsig = gpgsig
123124

124125
@classmethod
125126
def _get_intermediate_items(cls, commit):
@@ -393,6 +394,12 @@ def _serialize(self, stream):
393394

394395
if self.encoding != self.default_encoding:
395396
write("encoding %s\n" % self.encoding)
397+
398+
if self.gpgsig:
399+
write("gpgsig")
400+
for sigline in self.gpgsig.split("\n"):
401+
write(" " + sigline + "\n")
402+
396403

397404
write("\n")
398405

@@ -430,13 +437,28 @@ def _deserialize(self, stream):
430437
# message.
431438
self.encoding = self.default_encoding
432439
# read encoding or empty line to separate message
433-
enc = readline()
434-
enc = enc.strip()
435-
if enc:
436-
self.encoding = enc[enc.find(' ')+1:]
437-
# now comes the message separator
438-
readline()
439-
# END handle encoding
440+
441+
# read headers
442+
buf = readline().strip()
443+
while buf != "":
444+
if buf[0:10] == "encoding ":
445+
self.encoding = buf[buf.find(' ')+1:]
446+
elif buf[0:7] == "gpgsig ":
447+
sig = buf[buf.find(' ')+1:] + "\n"
448+
is_next_header = False
449+
while True:
450+
sigbuf = readline()
451+
if sigbuf == "": break
452+
if sigbuf[0:1] != " ":
453+
buf = sigbuf.strip()
454+
is_next_header = True
455+
break
456+
sig += sigbuf[1:]
457+
self.gpgsig = sig
458+
if is_next_header:
459+
continue
460+
buf = readline().strip()
461+
440462

441463
# decode the authors name
442464
try:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.