Skip to content

Commit f13791c

Browse files
authored
Merge pull request #77 from alexander-nitsche/task-support-prerelease-semver
Support pre-release semantic versioning
2 parents 0431d5c + 72acbff commit f13791c

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
.github export-ignore
33
build export-ignore
44
tests export-ignore
5-
demo.php export-ignore
65
.gitattributes export-ignore
76
.gitignore export-ignore
7+
demo.php export-ignore
88
index.html export-ignore
99
phpunit.xml export-ignore

.gitignore

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/.idea
2-
/nbproject/private/
3-
/build/logs/
4-
/cache/
1+
.phpunit.result.cache
2+
3+
/.idea/
54
/nbproject/
6-
/debug/
7-
/composer.lock
85
/vendor/
6+
/composer.lock

build/classes/SemanticVersioning.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ class SemanticVersioning
1111
public function getNextReleaseTag($tag, $releaseType)
1212
{
1313
$tagPrefix = substr($tag, 0, strcspn($tag, '0123456789'));
14-
$tagVersion = substr($tag, strlen($tagPrefix));
14+
if (($tagSuffixPos = strpos($tag, '-')) !== false) {
15+
$tagVersion = substr($tag, strlen($tagPrefix), $tagSuffixPos);
16+
} else {
17+
$tagVersion = substr($tag, strlen($tagPrefix));
18+
}
1519
$tagVersionParts = explode('.', $tagVersion);
1620
$releaseVersionParts = $tagVersionParts + [0, 0, 0];
1721
$releaseVersionParts = array_slice($releaseVersionParts, 0, $releaseType + 1);

tests/build/SemanticVersioningTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function getNextReleaseTagDataProvider()
3737
['1', SemanticVersioning::MINOR_RELEASE, '1.1'],
3838
['1', SemanticVersioning::MAJOR_RELEASE, '2'],
3939
['v1.0.1', SemanticVersioning::PATCH_RELEASE, 'v1.0.2'],
40+
['1.0.1-p1', SemanticVersioning::PATCH_RELEASE, '1.0.2'],
4041
];
4142
}
4243

0 commit comments

Comments
 (0)