Skip to content

Commit 56d7a9b

Browse files
author
Yuriy Arhipov
committed
[#7021] ticket:533 fixed error with pgp signed commits
1 parent b8f10e7 commit 56d7a9b

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

‎git/objects/commit.py‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
5858
__slots__= ("tree",
5959
"author", "authored_date", "author_tz_offset",
6060
"committer", "committed_date", "committer_tz_offset",
61-
"message", "parents", "encoding")
61+
"message", "parents", "encoding", "gpgsig")
6262
_id_attribute_="binsha"
6363

6464
def__init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
6565
committer=None, committed_date=None, committer_tz_offset=None,
66-
message=None, parents=None, encoding=None):
66+
message=None, parents=None, encoding=None, gpgsig=None):
6767
"""Instantiate a new Commit. All keyword arguments taking None as default will
6868
be implicitly set on first query.
6969
@@ -121,6 +121,8 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
121121
self.parents=parents
122122
ifencodingisnotNone:
123123
self.encoding=encoding
124+
ifgpgsigisnotNone:
125+
self.gpgsig=gpgsig
124126

125127
@classmethod
126128
def_get_intermediate_items(cls, commit):
@@ -439,15 +441,29 @@ def _deserialize(self, stream):
439441
# now we can have the encoding line, or an empty line followed by the optional
440442
# message.
441443
self.encoding=self.default_encoding
442-
# read encoding or empty line to separate message
444+
445+
# read headers
443446
enc=next_line
444-
enc=enc.strip()
445-
ifenc:
446-
self.encoding=enc[enc.find(' ')+1:]
447-
# now comes the message separator
448-
readline()
449-
# END handle encoding
450-
447+
buf=enc.strip()
448+
whilebuf!="":
449+
ifbuf[0:10] =="encoding ":
450+
self.encoding=buf[buf.find(' ')+1:]
451+
elifbuf[0:7] =="gpgsig ":
452+
sig=buf[buf.find(' ')+1:] +"\n"
453+
is_next_header=False
454+
whileTrue:
455+
sigbuf=readline()
456+
ifsigbuf=="": break
457+
ifsigbuf[0:1] !=" ":
458+
buf=sigbuf.strip()
459+
is_next_header=True
460+
break
461+
sig+=sigbuf[1:]
462+
self.gpgsig=sig.rstrip("\n")
463+
ifis_next_header:
464+
continue
465+
buf=readline().strip()
466+
451467
# decode the authors name
452468
try:
453469
self.author.name=self.author.name.decode(self.encoding)

0 commit comments

Comments
(0)