From c6de6c94c1981ef65963d8740ecc21b39a504770 Mon Sep 17 00:00:00 2001 From: Alexander Nitsche Date: Tue, 20 Jun 2023 12:42:22 +0200 Subject: [PATCH 1/2] TASK: Support pre-release tags in next release tag calculation The calculation of the next version with a pre-release suffix in the current version failed, e.g. the calculation of the next patch version 1.2.2 for the current pre-release version 1.2.1-p1. --- build/classes/SemanticVersioning.php | 6 +++++- tests/build/SemanticVersioningTest.php | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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'], ]; } From 72acbff26f4e517c56d722a417f182d1f5bcced7 Mon Sep 17 00:00:00 2001 From: Alexander Nitsche Date: Tue, 20 Jun 2023 12:54:59 +0200 Subject: [PATCH 2/2] TASK: Clean up .gitattributes and .gitignore 1. Sort entries by name. 2. Remove redundant "/nbproject/" and "/nbproject/private/". 3. Remove outdated "/build/logs/", "/cache/", "/debug/". --- .gitattributes | 2 +- .gitignore | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) 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