Skip to content

Commit

Permalink
Fix rbt land --squash when landing a review request.
Browse files Browse the repository at this point in the history
`rbt land --squash` was correctly squashing commits when landing a local
branch, but not when loading a review request with multiple commits. All
the work to handle squashing a patch was already done, but we just
weren't plumbing the `--squash` argument to `rbt patch` to trigger it.

This is a simple change that adds the missing argument, fixing squashing
of multi-commit review requests.

Testing Done:
Successfully landed a multi-commit review request with `--squash`.

Reviewed at https://reviews.reviewboard.org/r/11296/
  • Loading branch information
chipx86 committed Nov 21, 2020
1 parent 408ddaa commit 44e698a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions rbtools/commands/land.py
Expand Up @@ -119,8 +119,20 @@ class Land(Command):
Command.branch_options,
]

def patch(self, review_request_id):
"""Patch a single review request's diff using rbt patch."""
def patch(self, review_request_id, squash=False):
"""Patch a single review request's diff using rbt patch.
Args:
review_request_id (int):
The ID of the review request to patch.
squash (bool, optional):
Whether to squash multiple commits into a single commit.
Raises:
rbtools.commands.CommandError:
There was an error applying the patch.
"""
patch_command = [RB_MAIN, 'patch']
patch_command.extend(build_rbtools_cmd_argv(self.options))

Expand All @@ -129,6 +141,9 @@ def patch(self, review_request_id):
else:
patch_command.append('-C')

if squash:
patch_command.append('--squash')

patch_command.append(six.text_type(review_request_id))

rc, output = execute(patch_command, ignore_errors=True,
Expand Down Expand Up @@ -230,7 +245,8 @@ def land(self, destination_branch, review_request, source_branch=None,
print('Applying patch from review request %s.' % review_request.id)

if not dry_run:
self.patch(review_request.id)
self.patch(review_request.id,
squash=squash)

print('Review request %s has landed on "%s".' %
(review_request.id, self.options.destination_branch))
Expand Down

0 comments on commit 44e698a

Please sign in to comment.