Validate prerelease suffix as a whole, not by parts
I have this template for prerelease suffix:
echo $GSG_PRE_TMPL
{{ (env "CI_COMMIT_REF_SLUG") }}, {{ (env "CI_COMMIT_SHORT_SHA") }}
These variables correspond to branch name and short commit hash. Example version generated by GSG: 1.0.0-branch_name.12ab34cd
Now if commit hash contains only decimal digits AND starts with zero, eg 01234567
, i get this error:
Creating new tag for release...
2022/06/30 01:45:30 pre version tmpl: Numeric PreRelease version must not contain leading zeroes "01234567"
I am aware of this semver rule not to start prerelease version, if it's decimal, from zero. OK, but i already include branch name before the hash! branch_name.01234567
So it is perfectly valid. GSG should not validate each separate template part for prerelease, it should validate whole result instead (the one joined by .
)
By the way, chances of getting this error are 2 in a billion, still i got it...
Edited by Rostislav Kirillov