Merge lp:~jelmer/brz/suggest-commit-message into lp:brz

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/suggest-commit-message
Merge into: lp:brz
Diff against target: 295 lines (+53/-19)
6 files modified
breezy/plugins/propose/cmds.py (+6/-2)
breezy/plugins/propose/github.py (+7/-1)
breezy/plugins/propose/gitlabs.py (+7/-1)
breezy/plugins/propose/launchpad.py (+15/-14)
breezy/plugins/propose/propose.py (+14/-1)
doc/en/release-notes/brz-3.1.txt (+4/-0)
To merge this branch: bzr merge lp:~jelmer/brz/suggest-commit-message
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+366610@code.launchpad.net

Commit message

Add commit-message option to 'brz propose'.h

Description of the change

Add commit-message option to 'brz propose'.

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/cmds.py'
2--- breezy/plugins/propose/cmds.py 2019-01-24 00:56:15 +0000
3+++ breezy/plugins/propose/cmds.py 2019-04-27 16:04:53 +0000
4@@ -143,6 +143,9 @@
5 Option('name', help='Name of the new remote branch.', type=str),
6 Option('description', help='Description of the change.', type=str),
7 Option('prerequisite', help='Prerequisite branch.', type=str),
8+ Option(
9+ 'commit-message',
10+ help='Set commit message for merge, if supported', type=str),
11 ListOption('labels', short_name='l', type=text_type,
12 help='Labels to apply.'),
13 Option('no-allow-lossy',
14@@ -154,7 +157,7 @@
15
16 def run(self, submit_branch=None, directory='.', hoster=None,
17 reviewers=None, name=None, no_allow_lossy=False, description=None,
18- labels=None, prerequisite=None):
19+ labels=None, prerequisite=None, commit_message=None):
20 tree, branch, relpath = (
21 controldir.ControlDir.open_containing_tree_or_branch(directory))
22 if submit_branch is None:
23@@ -191,7 +194,8 @@
24 try:
25 proposal = proposal_builder.create_proposal(
26 description=description, reviewers=reviewers,
27- prerequisite_branch=prerequisite_branch, labels=labels)
28+ prerequisite_branch=prerequisite_branch, labels=labels,
29+ commit_message=commit_message)
30 except _mod_propose.MergeProposalExists as e:
31 raise errors.BzrCommandError(gettext(
32 'There is already a branch merge proposal: %s') % e.url)
33
34=== modified file 'breezy/plugins/propose/github.py'
35--- breezy/plugins/propose/github.py 2019-02-14 19:33:19 +0000
36+++ breezy/plugins/propose/github.py 2019-04-27 16:04:53 +0000
37@@ -27,6 +27,7 @@
38 MergeProposalBuilder,
39 MergeProposalExists,
40 PrerequisiteBranchUnsupported,
41+ CommitMessageUnsupported,
42 UnsupportedHoster,
43 )
44
45@@ -122,6 +123,9 @@
46 def get_description(self):
47 return self._pr.body
48
49+ def get_commit_message(self):
50+ return None
51+
52 def set_description(self, description):
53 self._pr.edit(body=description, title=determine_title(description))
54
55@@ -173,6 +177,7 @@
56 name = 'github'
57
58 supports_merge_proposal_labels = True
59+ supports_merge_proposal_commit_message = False
60
61 def __repr__(self):
62 return "GitHub()"
63@@ -346,10 +351,11 @@
64 return None
65
66 def create_proposal(self, description, reviewers=None, labels=None,
67- prerequisite_branch=None):
68+ prerequisite_branch=None, commit_message=None):
69 """Perform the submission."""
70 if prerequisite_branch is not None:
71 raise PrerequisiteBranchUnsupported(self)
72+ # Note that commit_message is ignored, since github doesn't support it.
73 import github
74 # TODO(jelmer): Probe for right repo name
75 if self.target_repo_name.endswith('.git'):
76
77=== modified file 'breezy/plugins/propose/gitlabs.py'
78--- breezy/plugins/propose/gitlabs.py 2019-02-14 19:33:19 +0000
79+++ breezy/plugins/propose/gitlabs.py 2019-04-27 16:04:53 +0000
80@@ -145,6 +145,9 @@
81 self._mr.description = description
82 self._mr.save()
83
84+ def get_commit_message(self):
85+ return None
86+
87 def _branch_url_from_project(self, project_id, branch_name):
88 project = self._mr.manager.gitlab.projects.get(project_id)
89 return gitlab_url_to_bzr_url(project.http_url_to_repo, branch_name)
90@@ -176,6 +179,7 @@
91 """GitLab hoster implementation."""
92
93 supports_merge_proposal_labels = True
94+ supports_merge_proposal_commit_message = False
95
96 def __repr__(self):
97 return "<GitLab(%r)>" % self.gl.url
98@@ -360,11 +364,13 @@
99 return None
100
101 def create_proposal(self, description, reviewers=None, labels=None,
102- prerequisite_branch=None):
103+ prerequisite_branch=None, commit_message=None):
104 """Perform the submission."""
105+ # https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
106 if prerequisite_branch is not None:
107 raise PrerequisiteBranchUnsupported(self)
108 import gitlab
109+ # Note that commit_message is ignored, since Gitlab doesn't support it.
110 # TODO(jelmer): Support reviewers
111 self.gl.auth()
112 source_project = self.gl.projects.get(self.source_project_name)
113
114=== modified file 'breezy/plugins/propose/launchpad.py'
115--- breezy/plugins/propose/launchpad.py 2019-03-06 14:03:19 +0000
116+++ breezy/plugins/propose/launchpad.py 2019-04-27 16:04:53 +0000
117@@ -142,6 +142,13 @@
118 self._mp.description = description
119 self._mp.lp_save()
120
121+ def get_commit_message(self):
122+ return self._mp.commit_message
123+
124+ def set_commit_message(self, commit_message):
125+ self._mp.commit_message = commit_message
126+ self._mp.lp_save()
127+
128 def close(self):
129 self._mp.setStatus(status='Rejected')
130
131@@ -154,6 +161,8 @@
132 # https://bugs.launchpad.net/launchpad/+bug/397676
133 supports_merge_proposal_labels = False
134
135+ supports_merge_proposal_commit_message = True
136+
137 def __init__(self, staging=False):
138 self._staging = staging
139 if staging:
140@@ -394,13 +403,12 @@
141
142 class LaunchpadBazaarMergeProposalBuilder(MergeProposalBuilder):
143
144- def __init__(self, lp_host, source_branch, target_branch, message=None,
145+ def __init__(self, lp_host, source_branch, target_branch,
146 staging=None, approve=None, fixes=None):
147 """Constructor.
148
149 :param source_branch: The branch to propose for merging.
150 :param target_branch: The branch to merge into.
151- :param message: The commit message to use. (May be None.)
152 :param staging: If True, propose the merge against staging instead of
153 production.
154 :param approve: If True, mark the new proposal as approved immediately.
155@@ -421,14 +429,11 @@
156 self.target_branch = target_branch
157 self.target_branch_lp = self.launchpad.branches.getByUrl(
158 url=target_branch.user_url)
159- self.commit_message = message
160 self.approve = approve
161 self.fixes = fixes
162
163 def get_infotext(self):
164 """Determine the initial comment for the merge proposal."""
165- if self.commit_message is not None:
166- return self.commit_message.strip().encode('utf-8')
167 info = ["Source: %s\n" % self.source_branch_lp.bzr_identity]
168 info.append("Target: %s\n" % self.target_branch_lp.bzr_identity)
169 return ''.join(info)
170@@ -480,7 +485,7 @@
171 revid=self.source_branch.last_revision())
172
173 def create_proposal(self, description, reviewers=None, labels=None,
174- prerequisite_branch=None):
175+ prerequisite_branch=None, commit_message=None):
176 """Perform the submission."""
177 if labels:
178 raise LabelsUnsupported()
179@@ -497,7 +502,7 @@
180 target_branch=self.target_branch_lp,
181 prerequisite_branch=prereq,
182 initial_comment=description.strip(),
183- commit_message=self.commit_message,
184+ commit_message=commit_message,
185 reviewers=[self.launchpad.people[reviewer].self_link
186 for reviewer in reviewers],
187 review_types=[None for reviewer in reviewers])
188@@ -521,13 +526,12 @@
189
190 class LaunchpadGitMergeProposalBuilder(MergeProposalBuilder):
191
192- def __init__(self, lp_host, source_branch, target_branch, message=None,
193+ def __init__(self, lp_host, source_branch, target_branch,
194 staging=None, approve=None, fixes=None):
195 """Constructor.
196
197 :param source_branch: The branch to propose for merging.
198 :param target_branch: The branch to merge into.
199- :param message: The commit message to use. (May be None.)
200 :param staging: If True, propose the merge against staging instead of
201 production.
202 :param approve: If True, mark the new proposal as approved immediately.
203@@ -549,14 +553,11 @@
204 self.target_branch = target_branch
205 (self.target_repo_lp, self.target_branch_lp) = (
206 self.lp_host._get_lp_git_ref_from_branch(target_branch))
207- self.commit_message = message
208 self.approve = approve
209 self.fixes = fixes
210
211 def get_infotext(self):
212 """Determine the initial comment for the merge proposal."""
213- if self.commit_message is not None:
214- return self.commit_message.strip().encode('utf-8')
215 info = ["Source: %s\n" % self.source_branch.user_url]
216 info.append("Target: %s\n" % self.target_branch.user_url)
217 return ''.join(info)
218@@ -609,7 +610,7 @@
219 revid=self.source_branch.last_revision())
220
221 def create_proposal(self, description, reviewers=None, labels=None,
222- prerequisite_branch=None):
223+ prerequisite_branch=None, commit_message=None):
224 """Perform the submission."""
225 if labels:
226 raise LabelsUnsupported()
227@@ -626,7 +627,7 @@
228 merge_target=self.target_branch_lp,
229 merge_prerequisite=prereq_branch_lp,
230 initial_comment=description.strip(),
231- commit_message=self.commit_message,
232+ commit_message=commit_message,
233 needs_review=True,
234 reviewers=[self.launchpad.people[reviewer].self_link
235 for reviewer in reviewers],
236
237=== modified file 'breezy/plugins/propose/propose.py'
238--- breezy/plugins/propose/propose.py 2019-02-15 02:29:10 +0000
239+++ breezy/plugins/propose/propose.py 2019-04-27 16:04:53 +0000
240@@ -111,6 +111,14 @@
241 """Set the description of the merge proposal."""
242 raise NotImplementedError(self.set_description)
243
244+ def get_commit_message(self):
245+ """Get the proposed commit message."""
246+ raise NotImplementedError(self.get_commit_message)
247+
248+ def set_commit_message(self, commit_message):
249+ """Set the propose commit message."""
250+ raise NotImplementedError(self.set_commit_message)
251+
252 def get_source_branch_url(self):
253 """Return the source branch."""
254 raise NotImplementedError(self.get_source_branch_url)
255@@ -154,13 +162,14 @@
256 raise NotImplementedError(self.get_infotext)
257
258 def create_proposal(self, description, reviewers=None, labels=None,
259- prerequisite_branch=None):
260+ prerequisite_branch=None, commit_message=None):
261 """Create a proposal to merge a branch for merging.
262
263 :param description: Description for the merge proposal
264 :param reviewers: Optional list of people to ask reviews from
265 :param labels: Labels to attach to the proposal
266 :param prerequisite_branch: Optional prerequisite branch
267+ :param commit_message: Optional commit message
268 :return: A `MergeProposal` object
269 """
270 raise NotImplementedError(self.create_proposal)
271@@ -174,6 +183,10 @@
272 # proposals?
273 supports_merge_proposal_labels = None
274
275+ # Does this hoster support suggesting a commit message in the
276+ # merge proposal?
277+ supports_merge_proposal_commit_message = None
278+
279 # The base_url that would be visible to users. I.e. https://github.com/
280 # rather than https://api.github.com/
281 base_url = None
282
283=== modified file 'doc/en/release-notes/brz-3.1.txt'
284--- doc/en/release-notes/brz-3.1.txt 2019-03-06 14:23:50 +0000
285+++ doc/en/release-notes/brz-3.1.txt 2019-04-27 16:04:53 +0000
286@@ -27,6 +27,10 @@
287 .. Improvements to existing commands, especially improved performance
288 or memory usage, or better results.
289
290+* A new ``--commit-message`` option has been added to
291+ ``brz propose``, for hosting sites that support it.
292+ (Jelmer Vernooij)
293+
294 Bug Fixes
295 *********
296

Subscribers

People subscribed via source and target branches