From 44e698a5e4a833b686062fb43948d9a518bcf7b0 Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Sat, 21 Nov 2020 00:15:23 -0800 Subject: [PATCH] Fix rbt land --squash when landing a review request. `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/ --- rbtools/commands/land.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/rbtools/commands/land.py b/rbtools/commands/land.py index 525ac092..6d04f746 100644 --- a/rbtools/commands/land.py +++ b/rbtools/commands/land.py @@ -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)) @@ -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, @@ -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))