From 5021b7942d1a0a523fda8d7358cc044cfc9557b1 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Tue, 1 Mar 2016 17:15:36 +0100 Subject: [PATCH] Fix PullRequestMerge shows wrong target with switch --- .../PullRequest/PullRequestMergeCommand.php | 8 +++++++- .../PullRequestMergeCommandTest.php | 20 +++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Command/PullRequest/PullRequestMergeCommand.php b/src/Command/PullRequest/PullRequestMergeCommand.php index fce15ff0..4024c9d4 100644 --- a/src/Command/PullRequest/PullRequestMergeCommand.php +++ b/src/Command/PullRequest/PullRequestMergeCommand.php @@ -143,11 +143,17 @@ protected function execute(InputInterface $input, OutputInterface $output) $gitConfigHelper->ensureRemoteExists($targetRemote, $targetRepository); $gitConfigHelper->ensureRemoteExists($sourceRemote, $sourceRepository); + if ($input->getOption('switch')) { + $targetLabel = sprintf('New-target: %s/%s (was "%s")', $targetRemote, $input->getOption('switch'), $targetBranch); + } else { + $targetLabel = sprintf('Target: %s/%s', $targetRemote, $targetBranch); + } + $styleHelper->title(sprintf('Merging pull-request #%d - %s', $prNumber, $pr['title'])); $styleHelper->text( [ sprintf('Source: %s/%s', $sourceRemote, $sourceBranch), - sprintf('Target: %s/%s', $targetRemote, $targetBranch), + $targetLabel, ] ); diff --git a/tests/Command/PullRequest/PullRequestMergeCommandTest.php b/tests/Command/PullRequest/PullRequestMergeCommandTest.php index ca204a38..aac14934 100644 --- a/tests/Command/PullRequest/PullRequestMergeCommandTest.php +++ b/tests/Command/PullRequest/PullRequestMergeCommandTest.php @@ -72,6 +72,10 @@ class PullRequestMergeCommandTest extends CommandTestCase const COMMAND_DISPLAY = <<getDisplay(); - $this->assertCommandOutputMatches(self::COMMAND_DISPLAY, $display); + + $this->assertCommandOutputMatches([self::COMMAND_DISPLAY, self::COMMAND_DISPLAY_TARGET], $display); } public function testMergePullRequestWithNoComments() @@ -276,7 +285,14 @@ function (HelperSet $helperSet) { ); $display = $tester->getDisplay(); - $this->assertCommandOutputMatches(sprintf(self::COMMAND_SWITCH_BASE, 'develop'), $display); + + $this->assertCommandOutputMatches( + [ + sprintf(self::COMMAND_SWITCH_BASE_TARGET, 'gushphp', 'develop', 'base_ref'), + sprintf(self::COMMAND_SWITCH_BASE, 'develop') + ], + $display + ); } public function testMergePullRequestWithFastForward()