Honour metadata added to version

closes https://github.com/therootcompany/go-gitver/issues/2
This commit is contained in:
Андрей Лухнов 2024-11-05 14:08:58 +03:00
parent 1638772379
commit ff518824b4
2 changed files with 13 additions and 1 deletions

View File

@ -14,7 +14,7 @@ var gitVer *regexp.Regexp
func init() {
// exactly vX.Y.Z (go-compatible semver)
exactVer = regexp.MustCompile(`^v\d+\.\d+\.\d+$`)
exactVer = regexp.MustCompile(`^v\d+\.\d+\.\d+(\+.*)?$`)
// vX.Y.Z-n-g0000000 git post-release, semver prerelease
// vX.Y.Z-dirty git post-release, semver prerelease

12
gitver/gitver_test.go Normal file
View File

@ -0,0 +1,12 @@
package gitver
import "fmt"
func Example_semVer_build_meta() {
fmt.Println(semVer("v1.5.0+something1"))
fmt.Println(semVer("v1.5.0"))
// Output:
// 1.5.0+something1 <nil>
// 1.5.0 <nil>
}