Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

GPG signature support on commit object.#57

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Changes fromall commits
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
35 changes: 23 additions & 12 deletionsgit/objects/commit.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ class Commit(Diffable, Iterable, RepoAliasMixin, base.Object, Traversable, Seria
__slots__ = ("tree",
"author", "authored_date", "author_tz_offset",
"committer", "committed_date", "committer_tz_offset",
"message", "parents", "encoding")
"message", "parents", "encoding", "gpgsig")
_id_attribute_ = "binsha"


Expand DownExpand Up@@ -264,7 +264,7 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False):

def __init__(self, odb, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
committer=None, committed_date=None, committer_tz_offset=None,
message=None, parents=None, encoding=None):
message=None, parents=None, encoding=None, gpgsig=None):
"""Instantiate a new Commit. All keyword arguments taking None as default will
be implicitly set on first query.

Expand DownExpand Up@@ -322,6 +322,9 @@ def __init__(self, odb, binsha, tree=None, author=None, authored_date=None, auth
self.parents = parents
if encoding is not None:
self.encoding = encoding
self.gpgsig = None
if gpgsig is not None:
self.gpgsig = gpgsig

@classmethod
def _get_intermediate_items(cls, commit):
Expand DownExpand Up@@ -399,6 +402,9 @@ def _serialize(self, stream):

if self.encoding != self.default_encoding:
write("encoding %s\n" % self.encoding)

if self.gpgsig:
write("gpgsig %s" % self.gpgsig)

write("\n")

Expand All@@ -407,7 +413,7 @@ def _serialize(self, stream):
write(self.message.encode(self.encoding))
else:
write(self.message)
# END handle encoding
# END handle encoding
return self

def _deserialize(self, stream):
Expand DownExpand Up@@ -435,15 +441,20 @@ def _deserialize(self, stream):
# now we can have the encoding line, or an empty line followed by the optional
# message.
self.encoding = self.default_encoding
# read encoding or empty line to separate message
enc = readline()
enc = enc.strip()
if enc:
self.encoding = enc[enc.find(' ')+1:]
# now comes the message separator
readline()
# END handle encoding


# read headers
buf = readline().strip()
while buf != "":
if buf[0:10] == "encoding ":
self.encoding = buf[buf.find(' ')+1:]
elif buf[0:7] == "gpgsig ":
sig = buf[buf.find(' ')+1:] + "\n"
while True:
sig += readline()
if sig.find("END PGP SIGNATURE") > -1: break
self.gpgsig = sig
buf = readline().strip()

# decode the authors name
try:
self.author.name = self.author.name.decode(self.encoding)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp