Skip to content

Commit

Permalink
Merge pull request #125 from kevincobain2000/version_match
Browse files Browse the repository at this point in the history
fix: check version before changing
  • Loading branch information
kevincobain2000 committed Sep 10, 2023
2 parents ca774a8 + 7f5a2ec commit 6d9a33b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gobrew.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ func (gb *GoBrew) ListVersions() {
version := versionSemantic.String()
// 1.8.0 -> 1.8, if version < 1.21.0
reMajorVersion := regexp.MustCompile("([0-9]+).([0-9]+).0")
vv, _ := strconv.Atoi(reMajorVersion.FindStringSubmatch(version)[2])
if vv < 21 {
if reMajorVersion.MatchString(version) {
version = strings.Split(version, ".")[0] + "." + strings.Split(version, ".")[1]
if len(reMajorVersion.FindStringSubmatch(version)) > 1 {
vv, _ := strconv.Atoi(reMajorVersion.FindStringSubmatch(version)[2])
if vv < 21 {
if reMajorVersion.MatchString(version) {
version = strings.Split(version, ".")[0] + "." + strings.Split(version, ".")[1]
}
}
}
if version == cv {
Expand Down

0 comments on commit 6d9a33b

Please sign in to comment.