Merge lp:~jelmer/brz/merge-proposal-text into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7447
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/merge-proposal-text
Merge into: lp:brz
Diff against target: 149 lines (+31/-9)
5 files modified
breezy/plugins/propose/github.py (+2/-4)
breezy/plugins/propose/gitlabs.py (+7/-5)
breezy/plugins/propose/launchpad.py (+2/-0)
breezy/propose.py (+9/-0)
breezy/tests/test_propose.py (+11/-0)
To merge this branch: bzr merge lp:~jelmer/brz/merge-proposal-text
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+377672@code.launchpad.net

Commit message

Add Hoster.merge_proposal_description_format and common function for determining title.

Description of the change

Add Hoster.merge_proposal_description_format and common function for determining title.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/plugins/propose/github.py'
2--- breezy/plugins/propose/github.py 2020-01-12 18:51:25 +0000
3+++ breezy/plugins/propose/github.py 2020-01-15 23:43:43 +0000
4@@ -22,6 +22,7 @@
5 import os
6
7 from ...propose import (
8+ determine_title,
9 Hoster,
10 HosterLoginRequired,
11 MergeProposal,
12@@ -71,10 +72,6 @@
13 return f.read().strip()
14
15
16-def determine_title(description):
17- return description.splitlines()[0]
18-
19-
20 class ValidationFailed(errors.BzrError):
21
22 _fmt = "GitHub validation failed: %(error)s"
23@@ -240,6 +237,7 @@
24
25 supports_merge_proposal_labels = True
26 supports_merge_proposal_commit_message = False
27+ merge_proposal_description_format = 'markdown'
28
29 def __repr__(self):
30 return "GitHub()"
31
32=== modified file 'breezy/plugins/propose/gitlabs.py'
33--- breezy/plugins/propose/gitlabs.py 2020-01-12 13:56:10 +0000
34+++ breezy/plugins/propose/gitlabs.py 2020-01-15 23:43:43 +0000
35@@ -35,6 +35,7 @@
36 from ...transport import get_transport
37
38 from ...propose import (
39+ determine_title,
40 Hoster,
41 MergeProposal,
42 MergeProposalBuilder,
43@@ -189,7 +190,7 @@
44 return self._mr['description']
45
46 def set_description(self, description):
47- self._update(description=description, title=description.splitlines()[0])
48+ self._update(description=description, title=determine_title(description))
49
50 def get_commit_message(self):
51 return self._mr.get('merge_commit_message')
52@@ -270,6 +271,7 @@
53
54 supports_merge_proposal_labels = True
55 supports_merge_proposal_commit_message = False
56+ merge_proposal_description_format = 'markdown'
57
58 def __repr__(self):
59 return "<GitLab(%r)>" % self.base_url
60@@ -548,11 +550,11 @@
61 return GitLabMergeProposal(mr)
62
63 def delete_project(self, project):
64- path = 'projects/%s' % urlutils.quote(str(project_name), '')
65+ path = 'projects/%s' % urlutils.quote(str(project), '')
66 response = self._api_request('DELETE', path)
67 if response.status == 404:
68- raise NoSuchProject(project_name)
69- if response.status != 200:
70+ raise NoSuchProject(project)
71+ if response.status != 202:
72 raise errors.InvalidHttpResponse(path, response.text)
73
74
75@@ -594,7 +596,7 @@
76 source_project = self.gl._get_project(self.source_project_name)
77 target_project = self.gl._get_project(self.target_project_name)
78 # TODO(jelmer): Allow setting title explicitly
79- title = description.splitlines()[0]
80+ title = determine_title(description)
81 # TODO(jelmer): Allow setting allow_collaboration field
82 # TODO(jelmer): Allow setting milestone field
83 # TODO(jelmer): Allow setting squash field
84
85=== modified file 'breezy/plugins/propose/launchpad.py'
86--- breezy/plugins/propose/launchpad.py 2020-01-11 16:22:12 +0000
87+++ breezy/plugins/propose/launchpad.py 2020-01-15 23:43:43 +0000
88@@ -199,6 +199,8 @@
89
90 supports_merge_proposal_commit_message = True
91
92+ merge_proposal_description_format = 'plain'
93+
94 def __init__(self, staging=False):
95 self._staging = staging
96 if staging:
97
98=== modified file 'breezy/propose.py'
99--- breezy/propose.py 2020-01-12 13:56:10 +0000
100+++ breezy/propose.py 2020-01-15 23:43:43 +0000
101@@ -230,6 +230,10 @@
102 # rather than https://api.github.com/
103 base_url = None
104
105+ # The syntax to use for formatting merge proposal descriptions.
106+ # Common values: 'plain', 'markdown'
107+ merge_proposal_description_format = None
108+
109 def publish_derived(self, new_branch, base_branch, name, project=None,
110 owner=None, revision_id=None, overwrite=False,
111 allow_lossy=True):
112@@ -330,6 +334,11 @@
113 raise NotImplementedError(cls.iter_instances)
114
115
116+def determine_title(description):
117+ """Determine the title for a merge proposal based on full description."""
118+ return description.splitlines()[0].split('.')[0]
119+
120+
121 def get_hoster(branch, possible_hosters=None):
122 """Find the hoster for a branch.
123
124
125=== modified file 'breezy/tests/test_propose.py'
126--- breezy/tests/test_propose.py 2019-10-27 14:11:56 +0000
127+++ breezy/tests/test_propose.py 2020-01-15 23:43:43 +0000
128@@ -17,6 +17,7 @@
129 import os
130
131 from ..propose import (
132+ determine_title,
133 get_proposal_by_url,
134 get_hoster,
135 Hoster,
136@@ -106,3 +107,13 @@
137
138 url = urlutils.local_path_to_url(os.path.join(self.test_dir, 'hosted', 'proposal'))
139 self.assertIsInstance(get_proposal_by_url(url), MergeProposal)
140+
141+
142+class DetermineTitleTests(tests.TestCase):
143+
144+ def test_determine_title(self):
145+ self.assertEqual('Make some change', determine_title("""\
146+Make some change.
147+
148+And here are some more details.
149+"""))

Subscribers

People subscribed via source and target branches