| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,15 +57,15 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): | |||
| 57 | 57 | __slots__ = ("tree", | |
| 58 | 58 | "author", "authored_date", "author_tz_offset", | |
| 59 | 59 | "committer", "committed_date", "committer_tz_offset", | |
| 60 | - "message", "parents", "encoding") | ||
| 60 | + "message", "parents", "encoding", "gpgsig") | ||
| 61 | 61 | _id_attribute_ = "binsha" | |
| 62 | 62 | ||
| 63 | 63 | def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None, | |
| 64 | - committer=None, committed_date=None, committer_tz_offset=None, | ||
| 65 | - message=None, parents=None, encoding=None): | ||
| 66 | - """Instantiate a new Commit. All keyword arguments taking None as default will | ||
| 67 | - be implicitly set on first query. | ||
| 68 | - | ||
| 64 | + committer=None, committed_date=None, committer_tz_offset=None, | ||
| 65 | + message=None, parents=None, encoding=None, gpgsig=None): | ||
| 66 | + """Instantiate a new Commit. All keyword arguments taking None as default will | ||
| 67 | + be implicitly set on first query. | ||
| 68 | + | ||
| 69 | 69 | :param binsha: 20 byte sha1 | |
| 70 | 70 | :param parents: tuple( Commit, ... ) | |
| 71 | 71 | is a tuple of commit ids or actual Commits | |
@@ -120,7 +120,8 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut | |||
| 120 | 120 | self.parents = parents | |
| 121 | 121 | if encoding is not None: | |
| 122 | 122 | self.encoding = encoding | |
| 123 | - | ||
| 123 | + self.gpgsig = gpgsig | ||
| 124 | + | ||
| 124 | 125 | @classmethod | |
| 125 | 126 | def _get_intermediate_items(cls, commit): | |
| 126 | 127 | return commit.parents | |
@@ -393,7 +394,12 @@ def _serialize(self, stream): | |||
| 393 | 394 | ||
| 394 | 395 | if self.encoding != self.default_encoding: | |
| 395 | 396 | write("encoding %s\n" % self.encoding) | |
| 396 | - | ||
| 397 | + | ||
| 398 | + if self.gpgsig: | ||
| 399 | + write("gpgsig") | ||
| 400 | + for sigline in self.gpgsig.rstrip("\n").split("\n"): | ||
| 401 | + write(" "+sigline+"\n") | ||
| 402 | + | ||
| 397 | 403 | write("\n") | |
| 398 | 404 | ||
| 399 | 405 | # write plain bytes, be sure its encoded according to our encoding | |
@@ -429,15 +435,28 @@ def _deserialize(self, stream): | |||
| 429 | 435 | # now we can have the encoding line, or an empty line followed by the optional | |
| 430 | 436 | # message. | |
| 431 | 437 | self.encoding = self.default_encoding | |
| 432 | - # 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 | - | ||
| 438 | + | ||
| 439 | + # read headers | ||
| 440 | + buf = readline().strip() | ||
| 441 | + while buf != "": | ||
| 442 | + if buf[0:10] == "encoding ": | ||
| 443 | + self.encoding = buf[buf.find(' ')+1:] | ||
| 444 | + elif buf[0:7] == "gpgsig ": | ||
| 445 | + sig = buf[buf.find(' ')+1:] + "\n" | ||
| 446 | + is_next_header = False | ||
| 447 | + while True: | ||
| 448 | + sigbuf = readline() | ||
| 449 | + if sigbuf == "": break | ||
| 450 | + if sigbuf[0:1] != " ": | ||
| 451 | + buf = sigbuf.strip() | ||
| 452 | + is_next_header = True | ||
| 453 | + break | ||
| 454 | + sig += sigbuf[1:] | ||
| 455 | + self.gpgsig = sig.rstrip("\n") | ||
| 456 | + if is_next_header: | ||
| 457 | + continue | ||
| 458 | + buf = readline().strip() | ||
| 459 | + | ||
| 441 | 460 | # decode the authors name | |
| 442 | 461 | try: | |
| 443 | 462 | self.author.name = self.author.name.decode(self.encoding) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + tree cefbccb4843d821183ae195e70a17c9938318945 | ||
| 2 | + parent 904435cf76a9bdd5eb41b1c4e049d5a64f3a8400 | ||
| 3 | + author Jon Mason <jon.mason@intel.com> 1367013117 -0700 | ||
| 4 | + committer Jon Mason <jon.mason@intel.com> 1368640702 -0700 | ||
| 5 | + gpgsig -----BEGIN PGP SIGNATURE----- | ||
| 6 | + Version: GnuPG v1.4.11 (GNU/Linux) | ||
| 7 | + | ||
| 8 | + iQIcBAABAgAGBQJRk8zMAAoJEG5mS6x6i9IjsTEP/0v2Wx/i7dqyKban6XMIhVdj | ||
| 9 | + uI0DycfXqnCCZmejidzeao+P+cuK/ZAA/b9fU4MtwkDm2USvnIOrB00W0isxsrED | ||
| 10 | + sdv6uJNa2ybGjxBolLrfQcWutxGXLZ1FGRhEvkPTLMHHvVriKoNFXcS7ewxP9MBf | ||
| 11 | + NH97K2wauqA+J4BDLDHQJgADCOmLrGTAU+G1eAXHIschDqa6PZMH5nInetYZONDh | ||
| 12 | + 3SkOOv8VKFIF7gu8X7HC+7+Y8k8U0TW0cjlQ2icinwCc+KFoG6GwXS7u/VqIo1Yp | ||
| 13 | + Tack6sxIdK7NXJhV5gAeAOMJBGhO0fHl8UUr96vGEKwtxyZhWf8cuIPOWLk06jA0 | ||
| 14 | + g9DpLqmy/pvyRfiPci+24YdYRBua/vta+yo/Lp85N7Hu/cpIh+q5WSLvUlv09Dmo | ||
| 15 | + TTTG8Hf6s3lEej7W8z2xcNZoB6GwXd8buSDU8cu0I6mEO9sNtAuUOHp2dBvTA6cX | ||
| 16 | + PuQW8jg3zofnx7CyNcd3KF3nh2z8mBcDLgh0Q84srZJCPRuxRcp9ylggvAG7iaNd | ||
| 17 | + XMNvSK8IZtWLkx7k3A3QYt1cN4y1zdSHLR2S+BVCEJea1mvUE+jK5wiB9S4XNtKm | ||
| 18 | + BX/otlTa8pNE3fWYBxURvfHnMY4i3HQT7Bc1QjImAhMnyo2vJk4ORBJIZ1FTNIhJ | ||
| 19 | + JzJMZDRLQLFvnzqZuCjE | ||
| 20 | + =przd | ||
| 21 | + -----END PGP SIGNATURE----- | ||
| 22 | + | ||
| 23 | + NTB: Multiple NTB client fix | ||
| 24 | + | ||
| 25 | + Fix issue with adding multiple ntb client devices to the ntb virtual | ||
| 26 | + bus. Previously, multiple devices would be added with the same name, | ||
| 27 | + resulting in crashes. To get around this issue, add a unique number to | ||
| 28 | + the device when it is added. | ||
| 29 | + | ||
| 30 | + Signed-off-by: Jon Mason <jon.mason@intel.com> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ | |||
| 13 | 13 | from cStringIO import StringIO | |
| 14 | 14 | import time | |
| 15 | 15 | import sys | |
| 16 | + import re | ||
| 16 | 17 | ||
| 17 | 18 | ||
| 18 | 19 | def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False): | |
@@ -272,4 +273,43 @@ def test_serialization_unicode_support(self): | |||
| 272 | 273 | # actually, it can't be printed in a shell as repr wants to have ascii only | |
| 273 | 274 | # it appears | |
| 274 | 275 | cmt.author.__repr__() | |
| 275 | - | ||
| 276 | + | ||
| 277 | + def test_gpgsig(self): | ||
| 278 | + cmt = self.rorepo.commit() | ||
| 279 | + cmt._deserialize(open(fixture_path('commit_with_gpgsig'))) | ||
| 280 | + | ||
| 281 | + fixture_sig = """-----BEGIN PGP SIGNATURE----- | ||
| 282 | + Version: GnuPG v1.4.11 (GNU/Linux) | ||
| 283 | + | ||
| 284 | + iQIcBAABAgAGBQJRk8zMAAoJEG5mS6x6i9IjsTEP/0v2Wx/i7dqyKban6XMIhVdj | ||
| 285 | + uI0DycfXqnCCZmejidzeao+P+cuK/ZAA/b9fU4MtwkDm2USvnIOrB00W0isxsrED | ||
| 286 | + sdv6uJNa2ybGjxBolLrfQcWutxGXLZ1FGRhEvkPTLMHHvVriKoNFXcS7ewxP9MBf | ||
| 287 | + NH97K2wauqA+J4BDLDHQJgADCOmLrGTAU+G1eAXHIschDqa6PZMH5nInetYZONDh | ||
| 288 | + 3SkOOv8VKFIF7gu8X7HC+7+Y8k8U0TW0cjlQ2icinwCc+KFoG6GwXS7u/VqIo1Yp | ||
| 289 | + Tack6sxIdK7NXJhV5gAeAOMJBGhO0fHl8UUr96vGEKwtxyZhWf8cuIPOWLk06jA0 | ||
| 290 | + g9DpLqmy/pvyRfiPci+24YdYRBua/vta+yo/Lp85N7Hu/cpIh+q5WSLvUlv09Dmo | ||
| 291 | + TTTG8Hf6s3lEej7W8z2xcNZoB6GwXd8buSDU8cu0I6mEO9sNtAuUOHp2dBvTA6cX | ||
| 292 | + PuQW8jg3zofnx7CyNcd3KF3nh2z8mBcDLgh0Q84srZJCPRuxRcp9ylggvAG7iaNd | ||
| 293 | + XMNvSK8IZtWLkx7k3A3QYt1cN4y1zdSHLR2S+BVCEJea1mvUE+jK5wiB9S4XNtKm | ||
| 294 | + BX/otlTa8pNE3fWYBxURvfHnMY4i3HQT7Bc1QjImAhMnyo2vJk4ORBJIZ1FTNIhJ | ||
| 295 | + JzJMZDRLQLFvnzqZuCjE | ||
| 296 | + =przd | ||
| 297 | + -----END PGP SIGNATURE-----""" | ||
| 298 | + assert cmt.gpgsig == fixture_sig | ||
| 299 | + | ||
| 300 | + cmt.gpgsig = "<test\ndummy\nsig>" | ||
| 301 | + assert cmt.gpgsig != fixture_sig | ||
| 302 | + | ||
| 303 | + cstream = StringIO() | ||
| 304 | + cmt._serialize(cstream) | ||
| 305 | + assert re.search(r"^gpgsig <test\n dummy\n sig>$", cstream.getvalue(), re.MULTILINE) | ||
| 306 | + | ||
| 307 | + cstream.seek(0) | ||
| 308 | + cmt.gpgsig = None | ||
| 309 | + cmt._deserialize(cstream) | ||
| 310 | + assert cmt.gpgsig == "<test\ndummy\nsig>" | ||
| 311 | + | ||
| 312 | + cmt.gpgsig = None | ||
| 313 | + cstream = StringIO() | ||
| 314 | + cmt._serialize(cstream) | ||
| 315 | + assert not re.search(r"^gpgsig ", cstream.getvalue(), re.MULTILINE) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments