From ff518824b4808d144ce0dbaf1baae780532b8f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9B=D1=83=D1=85?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2?= Date: Tue, 5 Nov 2024 14:08:58 +0300 Subject: [PATCH] Honour metadata added to version closes https://github.com/therootcompany/go-gitver/issues/2 --- gitver/gitver.go | 2 +- gitver/gitver_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gitver/gitver_test.go diff --git a/gitver/gitver.go b/gitver/gitver.go index 1c00863..2575595 100644 --- a/gitver/gitver.go +++ b/gitver/gitver.go @@ -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 diff --git a/gitver/gitver_test.go b/gitver/gitver_test.go new file mode 100644 index 0000000..8760c78 --- /dev/null +++ b/gitver/gitver_test.go @@ -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 + // 1.5.0 +}