Guest User

gpg.patch

a guest
Jul 17th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. diff --git a/git/objects/commit.py b/git/objects/commit.py
  2. index cbfd509..88b3042 100644
  3. --- a/git/objects/commit.py
  4. +++ b/git/objects/commit.py
  5. @@ -57,12 +57,12 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
  6. __slots__ = ("tree",
  7. "author", "authored_date", "author_tz_offset",
  8. "committer", "committed_date", "committer_tz_offset",
  9. - "message", "parents", "encoding")
  10. + "message", "parents", "encoding", "gpgsig")
  11. _id_attribute_ = "binsha"
  12.  
  13. def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
  14. committer=None, committed_date=None, committer_tz_offset=None,
  15. - message=None, parents=None, encoding=None):
  16. + message=None, parents=None, encoding=None, gpgsig=None):
  17. """Instantiate a new Commit. All keyword arguments taking None as default will
  18. be implicitly set on first query.
  19.  
  20. @@ -120,6 +120,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
  21. self.parents = parents
  22. if encoding is not None:
  23. self.encoding = encoding
  24. + self.gpgsig = gpgsig
  25.  
  26. @classmethod
  27. def _get_intermediate_items(cls, commit):
  28. @@ -393,7 +394,12 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
  29.  
  30. if self.encoding != self.default_encoding:
  31. write("encoding %s\n" % self.encoding)
  32. -
  33. +
  34. + if self.gpgsig:
  35. + write("gpgsig")
  36. + for sigline in self.gpgsig.rstrip("\n").split("\n"):
  37. + write(" " + sigline + "\n")
  38. +
  39. write("\n")
  40.  
  41. # write plain bytes, be sure its encoded according to our encoding
  42. @@ -429,15 +435,29 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
  43. # now we can have the encoding line, or an empty line followed by the optional
  44. # message.
  45. self.encoding = self.default_encoding
  46. - # read encoding or empty line to separate message
  47. - enc = readline()
  48. - enc = enc.strip()
  49. - if enc:
  50. - self.encoding = enc[enc.find(' ')+1:]
  51. - # now comes the message separator
  52. - readline()
  53. - # END handle encoding
  54. -
  55. +
  56. + # read headers
  57. + buf = readline().strip()
  58. + while buf != "":
  59. + if buf[0:10] == "encoding ":
  60. + self.encoding = buf[buf.find(' ')+1:]
  61. + elif buf[0:7] == "gpgsig ":
  62. + sig = buf[buf.find(' ')+1:] + "\n"
  63. + is_next_header = False
  64. + while True:
  65. + sigbuf = readline()
  66. + if sigbuf == "":
  67. + break
  68. + if sigbuf[0:1] != " ":
  69. + buf = sigbuf.strip()
  70. + is_next_header = True
  71. + break
  72. + sig += sigbuf[1:]
  73. + self.gpgsig = sig.rstrip("\n")
  74. + if is_next_header:
  75. + continue
  76. + buf = readline().strip()
  77. +
  78. # decode the authors name
  79. try:
  80. self.author.name = self.author.name.decode(self.encoding)
Advertisement
Add Comment
Please, Sign In to add comment