diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-08-21 09:24:23 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2016-08-21 09:32:20 +0200 |
commit | 31ad0a0e2588819e791f4269a5d7d7e81a67f8cc (patch) | |
tree | 6c4ef86e3277eb9e89dfb8bfb657cb19ae8b21bf /git/objects/commit.py | |
parent | df5095c16894e6f4da814302349e8e32f84c8c13 (diff) | |
download | gitpython-31ad0a0e2588819e791f4269a5d7d7e81a67f8cc.tar.gz |
fix(commit): handle gpgsig properly
Assure that gpgsig is not initialized with None
to allow the automatic deserialization to kick in.
Fixes #500
Diffstat (limited to 'git/objects/commit.py')
-rw-r--r-- | git/objects/commit.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/git/objects/commit.py b/git/objects/commit.py index 9e434c92..000ab3d0 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -130,7 +130,8 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): self.parents = parents if encoding is not None: self.encoding = encoding - self.gpgsig = gpgsig + if gpgsig is not None: + self.gpgsig = gpgsig @classmethod def _get_intermediate_items(cls, commit): @@ -425,10 +426,13 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): if self.encoding != self.default_encoding: write(("encoding %s\n" % self.encoding).encode('ascii')) - if self.gpgsig: - write(b"gpgsig") - for sigline in self.gpgsig.rstrip("\n").split("\n"): - write((" " + sigline + "\n").encode('ascii')) + try: + if self.__getattribute__('gpgsig') is not None: + write(b"gpgsig") + for sigline in self.gpgsig.rstrip("\n").split("\n"): + write((" " + sigline + "\n").encode('ascii')) + except AttributeError: + pass write(b"\n") @@ -473,6 +477,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): # now we can have the encoding line, or an empty line followed by the optional # message. self.encoding = self.default_encoding + self.gpgsig = None # read headers enc = next_line |