mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Go: Output setup-go compatible pre-release identifiers
This commit is contained in:
@@ -132,5 +132,10 @@ func (ver semVer) MajorMinor() SemVer {
|
||||
}
|
||||
|
||||
func (ver semVer) StandardSemVer() string {
|
||||
return string(ver)[1:]
|
||||
// Drop the 'v' prefix from the version string.
|
||||
result := string(ver)[1:]
|
||||
|
||||
// Correct the pre-release identifier for use with `setup-go`, if one is present.
|
||||
// This still remains a standard semantic version.
|
||||
return strings.Replace(result, "-rc", "-rc.", 1)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
@@ -52,6 +53,8 @@ func TestNewSemVer(t *testing.T) {
|
||||
result,
|
||||
)
|
||||
}
|
||||
|
||||
expected = strings.Replace(expected, "-rc1", "-rc.1", 1)
|
||||
if result.StandardSemVer() != expected[1:] {
|
||||
t.Errorf(
|
||||
"Expected NewSemVer(\"%s\").StandardSemVer() to return \"%s\", but got \"%s\".",
|
||||
|
||||
Reference in New Issue
Block a user