diff --git a/.gitattributes b/.gitattributes index aef855b..6b06107 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore index cd6be76..04e2aa5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ -/.idea -/nbproject/private/ -/build/logs/ -/cache/ +.phpunit.result.cache + +/.idea/ /nbproject/ -/debug/ -/composer.lock /vendor/ +/composer.lock diff --git a/build/classes/SemanticVersioning.php b/build/classes/SemanticVersioning.php index 8842c44..5dd54ec 100644 --- a/build/classes/SemanticVersioning.php +++ b/build/classes/SemanticVersioning.php @@ -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); diff --git a/tests/build/SemanticVersioningTest.php b/tests/build/SemanticVersioningTest.php index 62dd8b7..ddc7f5a 100644 --- a/tests/build/SemanticVersioningTest.php +++ b/tests/build/SemanticVersioningTest.php @@ -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'], ]; }