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
1diff --git a/requirements.txt b/requirements.txt
2index 6d50d36..b706f3c 100644
3--- a/requirements.txt
4+++ b/requirements.txt
5@@ -33,7 +33,7 @@ pyasn1==0.1.7
6 pycparser==2.10
7 pycrypto==2.6.1
8 pyflakes==0.8.1
9-pygit2==0.27.2
10+pygit2==0.27.4
11 pyramid==1.5.4
12 python-mimeparse==0.1.4
13 # XXX: deryck 2012-08-10
14diff --git a/setup.py b/setup.py
15index c7ccd2a..24ef980 100755
16--- a/setup.py
17+++ b/setup.py
18@@ -22,7 +22,7 @@ requires = [
19 'cornice',
20 'lazr.sshserver>=0.1.7',
21 'Paste',
22- 'pygit2>=0.27.2,<0.28.0',
23+ 'pygit2>=0.27.4,<0.28.0',
24 'python-openid',
25 'PyYAML',
26 'Twisted[conch]',
27diff --git a/turnip/api/store.py b/turnip/api/store.py
28index 650a3d8..499182e 100644
29--- a/turnip/api/store.py
30+++ b/turnip/api/store.py
31@@ -55,20 +55,9 @@ def format_commit(git_object):
32 raise GitError('Invalid type: object {} is not a commit.'.format(
33 git_object.oid.hex))
34 parents = [parent.hex for parent in git_object.parent_ids]
35- # XXX cjwatson 2018-11-15: A regression in pygit2 0.27.1 means that we
36- # have to decode the commit message ourselves. See:
37- # https://github.com/libgit2/pygit2/issues/839
38- if git_object.message_encoding is not None:
39- message = git_object.raw_message.decode(
40- encoding=git_object.message_encoding, errors="strict")
41- else:
42- # If the encoding is not explicit, it may not be UTF-8, so it is not
43- # safe to decode it strictly.
44- message = git_object.raw_message.decode(
45- encoding="UTF-8", errors="replace")
46 return {
47 'sha1': git_object.oid.hex,
48- 'message': message,
49+ 'message': git_object.message,
50 'author': format_signature(git_object.author),
51 'committer': format_signature(git_object.committer),
52 'parents': parents,
53diff --git a/turnip/api/tests/test_api.py b/turnip/api/tests/test_api.py
54index f435d75..303a84b 100644
55--- a/turnip/api/tests/test_api.py
56+++ b/turnip/api/tests/test_api.py
57@@ -204,7 +204,7 @@ class ApiTestCase(TestCase):
58 self.assertTrue(ref in body)
59 self.assertTrue(self.tag.get('ref') in body)
60
61- oid = repo.head.get_object().oid.hex # git object sha
62+ oid = repo.head.peel().oid.hex # git object sha
63 resp_sha = body[ref]['object'].get('sha1')
64 self.assertEqual(oid, resp_sha)
65
66diff --git a/turnip/api/tests/test_helpers.py b/turnip/api/tests/test_helpers.py
67index 28ed9df..bf55b2e 100644
68--- a/turnip/api/tests/test_helpers.py
69+++ b/turnip/api/tests/test_helpers.py
70@@ -132,7 +132,7 @@ class RepoFactory(object):
71 def generate_tags(self, num_tags):
72 """Generate n number of tags."""
73 repo = self.repo
74- oid = repo.head.get_object().oid
75+ oid = repo.head.peel().oid
76 for i in range(num_tags):
77 self.add_tag('tag{}'.format(i), 'tag message {}'.format(i), oid)
78

Subscribers

People subscribed via source and target branches