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
=== modified file 'breezy/plugins/propose/cmds.py'
--- breezy/plugins/propose/cmds.py 2019-01-24 00:56:15 +0000
+++ breezy/plugins/propose/cmds.py 2019-04-27 16:04:53 +0000
@@ -143,6 +143,9 @@
143 Option('name', help='Name of the new remote branch.', type=str),143 Option('name', help='Name of the new remote branch.', type=str),
144 Option('description', help='Description of the change.', type=str),144 Option('description', help='Description of the change.', type=str),
145 Option('prerequisite', help='Prerequisite branch.', type=str),145 Option('prerequisite', help='Prerequisite branch.', type=str),
146 Option(
147 'commit-message',
148 help='Set commit message for merge, if supported', type=str),
146 ListOption('labels', short_name='l', type=text_type,149 ListOption('labels', short_name='l', type=text_type,
147 help='Labels to apply.'),150 help='Labels to apply.'),
148 Option('no-allow-lossy',151 Option('no-allow-lossy',
@@ -154,7 +157,7 @@
154157
155 def run(self, submit_branch=None, directory='.', hoster=None,158 def run(self, submit_branch=None, directory='.', hoster=None,
156 reviewers=None, name=None, no_allow_lossy=False, description=None,159 reviewers=None, name=None, no_allow_lossy=False, description=None,
157 labels=None, prerequisite=None):160 labels=None, prerequisite=None, commit_message=None):
158 tree, branch, relpath = (161 tree, branch, relpath = (
159 controldir.ControlDir.open_containing_tree_or_branch(directory))162 controldir.ControlDir.open_containing_tree_or_branch(directory))
160 if submit_branch is None:163 if submit_branch is None:
@@ -191,7 +194,8 @@
191 try:194 try:
192 proposal = proposal_builder.create_proposal(195 proposal = proposal_builder.create_proposal(
193 description=description, reviewers=reviewers,196 description=description, reviewers=reviewers,
194 prerequisite_branch=prerequisite_branch, labels=labels)197 prerequisite_branch=prerequisite_branch, labels=labels,
198 commit_message=commit_message)
195 except _mod_propose.MergeProposalExists as e:199 except _mod_propose.MergeProposalExists as e:
196 raise errors.BzrCommandError(gettext(200 raise errors.BzrCommandError(gettext(
197 'There is already a branch merge proposal: %s') % e.url)201 'There is already a branch merge proposal: %s') % e.url)
198202
=== modified file 'breezy/plugins/propose/github.py'
--- breezy/plugins/propose/github.py 2019-02-14 19:33:19 +0000
+++ breezy/plugins/propose/github.py 2019-04-27 16:04:53 +0000
@@ -27,6 +27,7 @@
27 MergeProposalBuilder,27 MergeProposalBuilder,
28 MergeProposalExists,28 MergeProposalExists,
29 PrerequisiteBranchUnsupported,29 PrerequisiteBranchUnsupported,
30 CommitMessageUnsupported,
30 UnsupportedHoster,31 UnsupportedHoster,
31 )32 )
3233
@@ -122,6 +123,9 @@
122 def get_description(self):123 def get_description(self):
123 return self._pr.body124 return self._pr.body
124125
126 def get_commit_message(self):
127 return None
128
125 def set_description(self, description):129 def set_description(self, description):
126 self._pr.edit(body=description, title=determine_title(description))130 self._pr.edit(body=description, title=determine_title(description))
127131
@@ -173,6 +177,7 @@
173 name = 'github'177 name = 'github'
174178
175 supports_merge_proposal_labels = True179 supports_merge_proposal_labels = True
180 supports_merge_proposal_commit_message = False
176181
177 def __repr__(self):182 def __repr__(self):
178 return "GitHub()"183 return "GitHub()"
@@ -346,10 +351,11 @@
346 return None351 return None
347352
348 def create_proposal(self, description, reviewers=None, labels=None,353 def create_proposal(self, description, reviewers=None, labels=None,
349 prerequisite_branch=None):354 prerequisite_branch=None, commit_message=None):
350 """Perform the submission."""355 """Perform the submission."""
351 if prerequisite_branch is not None:356 if prerequisite_branch is not None:
352 raise PrerequisiteBranchUnsupported(self)357 raise PrerequisiteBranchUnsupported(self)
358 # Note that commit_message is ignored, since github doesn't support it.
353 import github359 import github
354 # TODO(jelmer): Probe for right repo name360 # TODO(jelmer): Probe for right repo name
355 if self.target_repo_name.endswith('.git'):361 if self.target_repo_name.endswith('.git'):
356362
=== modified file 'breezy/plugins/propose/gitlabs.py'
--- breezy/plugins/propose/gitlabs.py 2019-02-14 19:33:19 +0000
+++ breezy/plugins/propose/gitlabs.py 2019-04-27 16:04:53 +0000
@@ -145,6 +145,9 @@
145 self._mr.description = description145 self._mr.description = description
146 self._mr.save()146 self._mr.save()
147147
148 def get_commit_message(self):
149 return None
150
148 def _branch_url_from_project(self, project_id, branch_name):151 def _branch_url_from_project(self, project_id, branch_name):
149 project = self._mr.manager.gitlab.projects.get(project_id)152 project = self._mr.manager.gitlab.projects.get(project_id)
150 return gitlab_url_to_bzr_url(project.http_url_to_repo, branch_name)153 return gitlab_url_to_bzr_url(project.http_url_to_repo, branch_name)
@@ -176,6 +179,7 @@
176 """GitLab hoster implementation."""179 """GitLab hoster implementation."""
177180
178 supports_merge_proposal_labels = True181 supports_merge_proposal_labels = True
182 supports_merge_proposal_commit_message = False
179183
180 def __repr__(self):184 def __repr__(self):
181 return "<GitLab(%r)>" % self.gl.url185 return "<GitLab(%r)>" % self.gl.url
@@ -360,11 +364,13 @@
360 return None364 return None
361365
362 def create_proposal(self, description, reviewers=None, labels=None,366 def create_proposal(self, description, reviewers=None, labels=None,
363 prerequisite_branch=None):367 prerequisite_branch=None, commit_message=None):
364 """Perform the submission."""368 """Perform the submission."""
369 # https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
365 if prerequisite_branch is not None:370 if prerequisite_branch is not None:
366 raise PrerequisiteBranchUnsupported(self)371 raise PrerequisiteBranchUnsupported(self)
367 import gitlab372 import gitlab
373 # Note that commit_message is ignored, since Gitlab doesn't support it.
368 # TODO(jelmer): Support reviewers374 # TODO(jelmer): Support reviewers
369 self.gl.auth()375 self.gl.auth()
370 source_project = self.gl.projects.get(self.source_project_name)376 source_project = self.gl.projects.get(self.source_project_name)
371377
=== modified file 'breezy/plugins/propose/launchpad.py'
--- breezy/plugins/propose/launchpad.py 2019-03-06 14:03:19 +0000
+++ breezy/plugins/propose/launchpad.py 2019-04-27 16:04:53 +0000
@@ -142,6 +142,13 @@
142 self._mp.description = description142 self._mp.description = description
143 self._mp.lp_save()143 self._mp.lp_save()
144144
145 def get_commit_message(self):
146 return self._mp.commit_message
147
148 def set_commit_message(self, commit_message):
149 self._mp.commit_message = commit_message
150 self._mp.lp_save()
151
145 def close(self):152 def close(self):
146 self._mp.setStatus(status='Rejected')153 self._mp.setStatus(status='Rejected')
147154
@@ -154,6 +161,8 @@
154 # https://bugs.launchpad.net/launchpad/+bug/397676161 # https://bugs.launchpad.net/launchpad/+bug/397676
155 supports_merge_proposal_labels = False162 supports_merge_proposal_labels = False
156163
164 supports_merge_proposal_commit_message = True
165
157 def __init__(self, staging=False):166 def __init__(self, staging=False):
158 self._staging = staging167 self._staging = staging
159 if staging:168 if staging:
@@ -394,13 +403,12 @@
394403
395class LaunchpadBazaarMergeProposalBuilder(MergeProposalBuilder):404class LaunchpadBazaarMergeProposalBuilder(MergeProposalBuilder):
396405
397 def __init__(self, lp_host, source_branch, target_branch, message=None,406 def __init__(self, lp_host, source_branch, target_branch,
398 staging=None, approve=None, fixes=None):407 staging=None, approve=None, fixes=None):
399 """Constructor.408 """Constructor.
400409
401 :param source_branch: The branch to propose for merging.410 :param source_branch: The branch to propose for merging.
402 :param target_branch: The branch to merge into.411 :param target_branch: The branch to merge into.
403 :param message: The commit message to use. (May be None.)
404 :param staging: If True, propose the merge against staging instead of412 :param staging: If True, propose the merge against staging instead of
405 production.413 production.
406 :param approve: If True, mark the new proposal as approved immediately.414 :param approve: If True, mark the new proposal as approved immediately.
@@ -421,14 +429,11 @@
421 self.target_branch = target_branch429 self.target_branch = target_branch
422 self.target_branch_lp = self.launchpad.branches.getByUrl(430 self.target_branch_lp = self.launchpad.branches.getByUrl(
423 url=target_branch.user_url)431 url=target_branch.user_url)
424 self.commit_message = message
425 self.approve = approve432 self.approve = approve
426 self.fixes = fixes433 self.fixes = fixes
427434
428 def get_infotext(self):435 def get_infotext(self):
429 """Determine the initial comment for the merge proposal."""436 """Determine the initial comment for the merge proposal."""
430 if self.commit_message is not None:
431 return self.commit_message.strip().encode('utf-8')
432 info = ["Source: %s\n" % self.source_branch_lp.bzr_identity]437 info = ["Source: %s\n" % self.source_branch_lp.bzr_identity]
433 info.append("Target: %s\n" % self.target_branch_lp.bzr_identity)438 info.append("Target: %s\n" % self.target_branch_lp.bzr_identity)
434 return ''.join(info)439 return ''.join(info)
@@ -480,7 +485,7 @@
480 revid=self.source_branch.last_revision())485 revid=self.source_branch.last_revision())
481486
482 def create_proposal(self, description, reviewers=None, labels=None,487 def create_proposal(self, description, reviewers=None, labels=None,
483 prerequisite_branch=None):488 prerequisite_branch=None, commit_message=None):
484 """Perform the submission."""489 """Perform the submission."""
485 if labels:490 if labels:
486 raise LabelsUnsupported()491 raise LabelsUnsupported()
@@ -497,7 +502,7 @@
497 target_branch=self.target_branch_lp,502 target_branch=self.target_branch_lp,
498 prerequisite_branch=prereq,503 prerequisite_branch=prereq,
499 initial_comment=description.strip(),504 initial_comment=description.strip(),
500 commit_message=self.commit_message,505 commit_message=commit_message,
501 reviewers=[self.launchpad.people[reviewer].self_link506 reviewers=[self.launchpad.people[reviewer].self_link
502 for reviewer in reviewers],507 for reviewer in reviewers],
503 review_types=[None for reviewer in reviewers])508 review_types=[None for reviewer in reviewers])
@@ -521,13 +526,12 @@
521526
522class LaunchpadGitMergeProposalBuilder(MergeProposalBuilder):527class LaunchpadGitMergeProposalBuilder(MergeProposalBuilder):
523528
524 def __init__(self, lp_host, source_branch, target_branch, message=None,529 def __init__(self, lp_host, source_branch, target_branch,
525 staging=None, approve=None, fixes=None):530 staging=None, approve=None, fixes=None):
526 """Constructor.531 """Constructor.
527532
528 :param source_branch: The branch to propose for merging.533 :param source_branch: The branch to propose for merging.
529 :param target_branch: The branch to merge into.534 :param target_branch: The branch to merge into.
530 :param message: The commit message to use. (May be None.)
531 :param staging: If True, propose the merge against staging instead of535 :param staging: If True, propose the merge against staging instead of
532 production.536 production.
533 :param approve: If True, mark the new proposal as approved immediately.537 :param approve: If True, mark the new proposal as approved immediately.
@@ -549,14 +553,11 @@
549 self.target_branch = target_branch553 self.target_branch = target_branch
550 (self.target_repo_lp, self.target_branch_lp) = (554 (self.target_repo_lp, self.target_branch_lp) = (
551 self.lp_host._get_lp_git_ref_from_branch(target_branch))555 self.lp_host._get_lp_git_ref_from_branch(target_branch))
552 self.commit_message = message
553 self.approve = approve556 self.approve = approve
554 self.fixes = fixes557 self.fixes = fixes
555558
556 def get_infotext(self):559 def get_infotext(self):
557 """Determine the initial comment for the merge proposal."""560 """Determine the initial comment for the merge proposal."""
558 if self.commit_message is not None:
559 return self.commit_message.strip().encode('utf-8')
560 info = ["Source: %s\n" % self.source_branch.user_url]561 info = ["Source: %s\n" % self.source_branch.user_url]
561 info.append("Target: %s\n" % self.target_branch.user_url)562 info.append("Target: %s\n" % self.target_branch.user_url)
562 return ''.join(info)563 return ''.join(info)
@@ -609,7 +610,7 @@
609 revid=self.source_branch.last_revision())610 revid=self.source_branch.last_revision())
610611
611 def create_proposal(self, description, reviewers=None, labels=None,612 def create_proposal(self, description, reviewers=None, labels=None,
612 prerequisite_branch=None):613 prerequisite_branch=None, commit_message=None):
613 """Perform the submission."""614 """Perform the submission."""
614 if labels:615 if labels:
615 raise LabelsUnsupported()616 raise LabelsUnsupported()
@@ -626,7 +627,7 @@
626 merge_target=self.target_branch_lp,627 merge_target=self.target_branch_lp,
627 merge_prerequisite=prereq_branch_lp,628 merge_prerequisite=prereq_branch_lp,
628 initial_comment=description.strip(),629 initial_comment=description.strip(),
629 commit_message=self.commit_message,630 commit_message=commit_message,
630 needs_review=True,631 needs_review=True,
631 reviewers=[self.launchpad.people[reviewer].self_link632 reviewers=[self.launchpad.people[reviewer].self_link
632 for reviewer in reviewers],633 for reviewer in reviewers],
633634
=== modified file 'breezy/plugins/propose/propose.py'
--- breezy/plugins/propose/propose.py 2019-02-15 02:29:10 +0000
+++ breezy/plugins/propose/propose.py 2019-04-27 16:04:53 +0000
@@ -111,6 +111,14 @@
111 """Set the description of the merge proposal."""111 """Set the description of the merge proposal."""
112 raise NotImplementedError(self.set_description)112 raise NotImplementedError(self.set_description)
113113
114 def get_commit_message(self):
115 """Get the proposed commit message."""
116 raise NotImplementedError(self.get_commit_message)
117
118 def set_commit_message(self, commit_message):
119 """Set the propose commit message."""
120 raise NotImplementedError(self.set_commit_message)
121
114 def get_source_branch_url(self):122 def get_source_branch_url(self):
115 """Return the source branch."""123 """Return the source branch."""
116 raise NotImplementedError(self.get_source_branch_url)124 raise NotImplementedError(self.get_source_branch_url)
@@ -154,13 +162,14 @@
154 raise NotImplementedError(self.get_infotext)162 raise NotImplementedError(self.get_infotext)
155163
156 def create_proposal(self, description, reviewers=None, labels=None,164 def create_proposal(self, description, reviewers=None, labels=None,
157 prerequisite_branch=None):165 prerequisite_branch=None, commit_message=None):
158 """Create a proposal to merge a branch for merging.166 """Create a proposal to merge a branch for merging.
159167
160 :param description: Description for the merge proposal168 :param description: Description for the merge proposal
161 :param reviewers: Optional list of people to ask reviews from169 :param reviewers: Optional list of people to ask reviews from
162 :param labels: Labels to attach to the proposal170 :param labels: Labels to attach to the proposal
163 :param prerequisite_branch: Optional prerequisite branch171 :param prerequisite_branch: Optional prerequisite branch
172 :param commit_message: Optional commit message
164 :return: A `MergeProposal` object173 :return: A `MergeProposal` object
165 """174 """
166 raise NotImplementedError(self.create_proposal)175 raise NotImplementedError(self.create_proposal)
@@ -174,6 +183,10 @@
174 # proposals?183 # proposals?
175 supports_merge_proposal_labels = None184 supports_merge_proposal_labels = None
176185
186 # Does this hoster support suggesting a commit message in the
187 # merge proposal?
188 supports_merge_proposal_commit_message = None
189
177 # The base_url that would be visible to users. I.e. https://github.com/190 # The base_url that would be visible to users. I.e. https://github.com/
178 # rather than https://api.github.com/191 # rather than https://api.github.com/
179 base_url = None192 base_url = None
180193
=== modified file 'doc/en/release-notes/brz-3.1.txt'
--- doc/en/release-notes/brz-3.1.txt 2019-03-06 14:23:50 +0000
+++ doc/en/release-notes/brz-3.1.txt 2019-04-27 16:04:53 +0000
@@ -27,6 +27,10 @@
27.. Improvements to existing commands, especially improved performance 27.. Improvements to existing commands, especially improved performance
28 or memory usage, or better results.28 or memory usage, or better results.
2929
30* A new ``--commit-message`` option has been added to
31 ``brz propose``, for hosting sites that support it.
32 (Jelmer Vernooij)
33
30Bug Fixes34Bug Fixes
31*********35*********
3236

Subscribers

People subscribed via source and target branches