Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix creation of new release branch when new major branch exists #255

Draft
wants to merge 2 commits into
base: 1.25.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions feature/automated-releases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down
3 changes: 3 additions & 0 deletions feature/default-branch-switching.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is currently violated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this isn't run, right now, BTW - @manually-tested above

We'd need to unit test this, probably, or add automation (which I was too lazy to do -.- my bad), since these .feature cases only act as documentation.

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
Expand Down
9 changes: 8 additions & 1 deletion src/Application/Command/SwitchDefaultBranchToNextMinor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
parent::__construct('laminas:automatic-releases:switch-default-branch-to-next-minor');
}

public function execute(InputInterface $input, OutputInterface $output): int

Check warning on line 34 in src/Application/Command/SwitchDefaultBranchToNextMinor.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.2, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ { parent::__construct('laminas:automatic-releases:switch-default-branch-to-next-minor'); } - public function execute(InputInterface $input, OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { $event = $this->loadGithubEvent->__invoke(); $repositoryPath = $this->variables->githubWorkspacePath();
{
$event = $this->loadGithubEvent->__invoke();
$repositoryPath = $this->variables->githubWorkspacePath();
Expand All @@ -58,9 +58,16 @@
$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)(
Expand Down
Loading