Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.17
go-version: '1.17'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.46.2
version: v1.50.1
4 changes: 1 addition & 3 deletions testing/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ func startServerWithApplication(
func getVersionFromDB(t *testing.T, db *sql.DB) *version.Version {
t.Helper()
var crdbVersion string
if err := db.QueryRow(
`SELECT value FROM crdb_internal.node_build_info where field = 'Version'`,
).Scan(&crdbVersion); err != nil {
if err := db.QueryRow("SHOW crdb_version").Scan(&crdbVersion); err != nil {
t.Fatal(err)
}
v, err := version.Parse(crdbVersion)
Expand Down
13 changes: 7 additions & 6 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,23 @@ func (v Version) String() string {
// of the form "vMAJOR.MINOR.PATCH[-PRERELEASE][+METADATA]". This
// conforms to https://semver.org/spec/v2.0.0.html
var versionRE = regexp.MustCompile(
`^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+|)?$`,
`v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+|)?`,
// ^major ^minor ^patch ^preRelease ^metadata
)

// numericRE is the regexp used to check if an identifier is numeric.
var numericRE = regexp.MustCompile(`^(0|[1-9][0-9]*)$`)

// Parse creates a version from a string. The string must be a valid semantic
// Parse creates a version from a string. The string must contain a valid semantic
// version (as per https://semver.org/spec/v2.0.0.html) in the format:
// "vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".
// "vMAJOR.MINOR.PATCH[-PRERELEASE][+METADATA]".
// MINOR, MAJOR, and PATCH are numeric values (without any leading 0s).
// PRERELEASE and METADATA can contain ASCII characters and digits, hyphens and
// dots.
func Parse(str string) (*Version, error) {
if !versionRE.MatchString(str) {
return nil, errors.Errorf("invalid version string '%s'", str)
func Parse(fullStr string) (*Version, error) {
var str string
if str = versionRE.FindString(fullStr); len(str) == 0 {
return nil, errors.Errorf("invalid version string '%s'", fullStr)
}

var v Version
Expand Down
Loading