Merge ~wgrant/turnip:pygit2-0.27.4 into turnip:master

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: 2c0f7f981f37682f5ae967ec618323195cf66cb3
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~wgrant/turnip:pygit2-0.27.4
Merge into: turnip:master
Diff against target: 77 lines (+5/-16)
5 files modified
requirements.txt (+1/-1)
setup.py (+1/-1)
turnip/api/store.py (+1/-12)
turnip/api/tests/test_api.py (+1/-1)
turnip/api/tests/test_helpers.py (+1/-1)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+363019@code.launchpad.net

Commit message

Upgrade to pygit2 0.27.4.

This fixes pygit2 #839, so we can remove our workaround and also stop
crashing on mis-encoded signatures.

0.27.4 helpfully removed the long-deprecated Reference.get_object(), so
use peel() instead.

LP: #1815517

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/requirements.txt b/requirements.txt
index 6d50d36..b706f3c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -33,7 +33,7 @@ pyasn1==0.1.7
33pycparser==2.1033pycparser==2.10
34pycrypto==2.6.134pycrypto==2.6.1
35pyflakes==0.8.135pyflakes==0.8.1
36pygit2==0.27.236pygit2==0.27.4
37pyramid==1.5.437pyramid==1.5.4
38python-mimeparse==0.1.438python-mimeparse==0.1.4
39# XXX: deryck 2012-08-1039# XXX: deryck 2012-08-10
diff --git a/setup.py b/setup.py
index c7ccd2a..24ef980 100755
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ requires = [
22 'cornice',22 'cornice',
23 'lazr.sshserver>=0.1.7',23 'lazr.sshserver>=0.1.7',
24 'Paste',24 'Paste',
25 'pygit2>=0.27.2,<0.28.0',25 'pygit2>=0.27.4,<0.28.0',
26 'python-openid',26 'python-openid',
27 'PyYAML',27 'PyYAML',
28 'Twisted[conch]',28 'Twisted[conch]',
diff --git a/turnip/api/store.py b/turnip/api/store.py
index 650a3d8..499182e 100644
--- a/turnip/api/store.py
+++ b/turnip/api/store.py
@@ -55,20 +55,9 @@ def format_commit(git_object):
55 raise GitError('Invalid type: object {} is not a commit.'.format(55 raise GitError('Invalid type: object {} is not a commit.'.format(
56 git_object.oid.hex))56 git_object.oid.hex))
57 parents = [parent.hex for parent in git_object.parent_ids]57 parents = [parent.hex for parent in git_object.parent_ids]
58 # XXX cjwatson 2018-11-15: A regression in pygit2 0.27.1 means that we
59 # have to decode the commit message ourselves. See:
60 # https://github.com/libgit2/pygit2/issues/839
61 if git_object.message_encoding is not None:
62 message = git_object.raw_message.decode(
63 encoding=git_object.message_encoding, errors="strict")
64 else:
65 # If the encoding is not explicit, it may not be UTF-8, so it is not
66 # safe to decode it strictly.
67 message = git_object.raw_message.decode(
68 encoding="UTF-8", errors="replace")
69 return {58 return {
70 'sha1': git_object.oid.hex,59 'sha1': git_object.oid.hex,
71 'message': message,60 'message': git_object.message,
72 'author': format_signature(git_object.author),61 'author': format_signature(git_object.author),
73 'committer': format_signature(git_object.committer),62 'committer': format_signature(git_object.committer),
74 'parents': parents,63 'parents': parents,
diff --git a/turnip/api/tests/test_api.py b/turnip/api/tests/test_api.py
index f435d75..303a84b 100644
--- a/turnip/api/tests/test_api.py
+++ b/turnip/api/tests/test_api.py
@@ -204,7 +204,7 @@ class ApiTestCase(TestCase):
204 self.assertTrue(ref in body)204 self.assertTrue(ref in body)
205 self.assertTrue(self.tag.get('ref') in body)205 self.assertTrue(self.tag.get('ref') in body)
206206
207 oid = repo.head.get_object().oid.hex # git object sha207 oid = repo.head.peel().oid.hex # git object sha
208 resp_sha = body[ref]['object'].get('sha1')208 resp_sha = body[ref]['object'].get('sha1')
209 self.assertEqual(oid, resp_sha)209 self.assertEqual(oid, resp_sha)
210210
diff --git a/turnip/api/tests/test_helpers.py b/turnip/api/tests/test_helpers.py
index 28ed9df..bf55b2e 100644
--- a/turnip/api/tests/test_helpers.py
+++ b/turnip/api/tests/test_helpers.py
@@ -132,7 +132,7 @@ class RepoFactory(object):
132 def generate_tags(self, num_tags):132 def generate_tags(self, num_tags):
133 """Generate n number of tags."""133 """Generate n number of tags."""
134 repo = self.repo134 repo = self.repo
135 oid = repo.head.get_object().oid135 oid = repo.head.peel().oid
136 for i in range(num_tags):136 for i in range(num_tags):
137 self.add_tag('tag{}'.format(i), 'tag message {}'.format(i), oid)137 self.add_tag('tag{}'.format(i), 'tag message {}'.format(i), oid)
138138

Subscribers

People subscribed via source and target branches