Skip to content

Commit

Permalink
Merge pull request #77 from alexander-nitsche/task-support-prerelease…
Browse files Browse the repository at this point in the history
…-semver

Support pre-release semantic versioning
  • Loading branch information
vanderlee authored Jul 4, 2023
2 parents 0431d5c + 72acbff commit f13791c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
.github export-ignore
build export-ignore
tests export-ignore
demo.php export-ignore
.gitattributes export-ignore
.gitignore export-ignore
demo.php export-ignore
index.html export-ignore
phpunit.xml export-ignore
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/.idea
/nbproject/private/
/build/logs/
/cache/
.phpunit.result.cache

/.idea/
/nbproject/
/debug/
/composer.lock
/vendor/
/composer.lock
6 changes: 5 additions & 1 deletion build/classes/SemanticVersioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ class SemanticVersioning
public function getNextReleaseTag($tag, $releaseType)
{
$tagPrefix = substr($tag, 0, strcspn($tag, '0123456789'));
$tagVersion = substr($tag, strlen($tagPrefix));
if (($tagSuffixPos = strpos($tag, '-')) !== false) {
$tagVersion = substr($tag, strlen($tagPrefix), $tagSuffixPos);
} else {
$tagVersion = substr($tag, strlen($tagPrefix));
}
$tagVersionParts = explode('.', $tagVersion);
$releaseVersionParts = $tagVersionParts + [0, 0, 0];
$releaseVersionParts = array_slice($releaseVersionParts, 0, $releaseType + 1);
Expand Down
1 change: 1 addition & 0 deletions tests/build/SemanticVersioningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function getNextReleaseTagDataProvider()
['1', SemanticVersioning::MINOR_RELEASE, '1.1'],
['1', SemanticVersioning::MAJOR_RELEASE, '2'],
['v1.0.1', SemanticVersioning::PATCH_RELEASE, 'v1.0.2'],
['1.0.1-p1', SemanticVersioning::PATCH_RELEASE, '1.0.2'],
];
}

Expand Down

0 comments on commit f13791c

Please sign in to comment.