diff --git a/feature/automated-releases.feature b/feature/automated-releases.feature index 5923fe8a..c64cfa93 100644 --- a/feature/automated-releases.feature +++ b/feature/automated-releases.feature @@ -13,7 +13,7 @@ Feature: Automated releases When I close milestone "2.0.0" Then the tool should have halted with an error - Scenario: If no major release branch exists, the tool should not create a new minor release + Scenario: If no matching minor release branch exists, the tool should not create a new minor release Given following existing branches: | name | | 1.0.x | @@ -38,7 +38,8 @@ Feature: Automated releases When I close milestone "2.0.0" Then tag "2.0.0" should have been created on branch "2.0.x" - Scenario: If a new major release branch exists, the tool does not create a new minor release + Scenario: If no matching minor release branch exists and new major release branch exists, + the tool does not create a new minor release Given following existing branches: | name | | 1.0.x | diff --git a/feature/default-branch-switching.feature b/feature/default-branch-switching.feature index d70aba3b..7efa2fbe 100644 --- a/feature/default-branch-switching.feature +++ b/feature/default-branch-switching.feature @@ -18,6 +18,7 @@ Feature: Default branch switching | 1.1.x | | 1.2.x | | 1.3.x | + And branch "1.3.x" should branch from "1.2.x" And the default branch should be "1.3.x" Scenario: The latest pre-existing minor release branch is set as default branch on a successful release @@ -59,6 +60,7 @@ Feature: Default branch switching | 1.2.x | | 2.0.x | | 2.1.x | + And branch "2.1.x" should branch from "2.0.x" And the default branch should be "2.1.x" Scenario: A pre-existing branch of a new major release is not set as default branch on release @@ -80,6 +82,7 @@ Feature: Default branch switching | 1.2.x | | 1.3.x | | 2.0.x | + And branch "1.3.x" should branch from "1.2.x" And the default branch should be "1.3.x" Scenario: A pre-existing minor branch of a greater major release is set as default branch on release diff --git a/src/Application/Command/SwitchDefaultBranchToNextMinor.php b/src/Application/Command/SwitchDefaultBranchToNextMinor.php index 8db1ce59..3ea57565 100644 --- a/src/Application/Command/SwitchDefaultBranchToNextMinor.php +++ b/src/Application/Command/SwitchDefaultBranchToNextMinor.php @@ -58,9 +58,16 @@ public function execute(InputInterface $input, OutputInterface $output): int $nextDefaultBranch = $mergeCandidates->newestFutureReleaseBranchAfter($releaseVersion); if (! $mergeCandidates->contains($nextDefaultBranch)) { + $baseBranch = $mergeCandidates->targetBranchFor($releaseVersion); + if ($baseBranch === null) { + $output->writeln('Target branch for release was not found'); + + return 1; + } + $this->push->__invoke( $repositoryPath, - $newestBranch->name(), + $baseBranch->name(), $nextDefaultBranch->name(), ); ($this->bumpChangelogVersion)(