Merge lp:~jelmer/brz/git-multiple-authors into lp:brz/3.2

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/git-multiple-authors
Merge into: lp:brz/3.2
Diff against target: 62 lines (+33/-1)
2 files modified
breezy/git/mapping.py (+4/-1)
breezy/git/tests/test_mapping.py (+29/-0)
To merge this branch: bzr merge lp:~jelmer/brz/git-multiple-authors
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+414072@code.launchpad.net

Commit message

Fix handling of invalid formatted authors field with multiple authors.

Description of the change

Fix handling of invalid formatted authors field with multiple authors.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/mapping.py'
2--- breezy/git/mapping.py 2021-08-18 22:38:08 +0000
3+++ breezy/git/mapping.py 2022-01-12 23:42:28 +0000
4@@ -310,8 +310,11 @@
5 pass
6 commit.committer = fix_person_identifier(rev.committer.encode(
7 encoding))
8+ first_author = rev.get_apparent_authors()[0]
9+ if ',' in first_author and first_author.count('>') > 1:
10+ first_author = first_author.split(',')[0]
11 commit.author = fix_person_identifier(
12- rev.get_apparent_authors()[0].encode(encoding))
13+ first_author.encode(encoding))
14 # TODO(jelmer): Don't use this hack.
15 long = getattr(__builtins__, 'long', int)
16 commit.commit_time = long(rev.timestamp)
17
18=== modified file 'breezy/git/tests/test_mapping.py'
19--- breezy/git/tests/test_mapping.py 2021-03-22 21:07:08 +0000
20+++ breezy/git/tests/test_mapping.py 2022-01-12 23:42:28 +0000
21@@ -300,6 +300,7 @@
22 self.assertEqual(list(orig_rev.parent_ids), list(rev.parent_ids))
23 else:
24 self.assertEqual({}, verifiers)
25+ return commit
26
27 def test_simple_commit(self):
28 r = Revision(self.mapping.revision_id_foreign_to_bzr(
29@@ -342,6 +343,34 @@
30 r.timezone = 0
31 self.assertRoundtripRevision(r)
32
33+ def test_multiple_authors(self):
34+ r = Revision(b"myrevid")
35+ r.message = u"MyCommitMessage"
36+ r.parent_ids = []
37+ r.properties = {
38+ u"authors":
39+ "Jelmer Vernooij <jelmer@jelmer.uk>\n"
40+ "Alex <alexa@example.com>"}
41+ r.committer = "Jelmer Vernooij <jelmer@apache.org>"
42+ r.timestamp = 453543543
43+ r.timezone = 0
44+ c = self.assertRoundtripRevision(r)
45+ self.assertEqual(c.author, b'Jelmer Vernooij <jelmer@jelmer.uk>')
46+
47+ def test_multiple_authors_comma(self):
48+ r = Revision(b"myrevid")
49+ r.message = u"MyCommitMessage"
50+ r.parent_ids = []
51+ r.properties = {
52+ u"authors":
53+ "Jelmer Vernooij <jelmer@jelmer.uk>, "
54+ "Alex <alexa@example.com>"}
55+ r.committer = "Jelmer Vernooij <jelmer@apache.org>"
56+ r.timestamp = 453543543
57+ r.timezone = 0
58+ c = self.assertRoundtripRevision(r)
59+ self.assertEqual(c.author, b'Jelmer Vernooij <jelmer@jelmer.uk>')
60+
61
62 class RoundtripRevisionsFromGit(tests.TestCase):
63

Subscribers

People subscribed via source and target branches