Skip to content

Commit 817a150

Browse files
committed
Check versions now only compares minor or above
Signed-off-by: Matt Stratton <[email protected]>
1 parent 0f14a90 commit 817a150

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

commands/config.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ func checkHugo() {
7171
if err != nil {
7272
log.Fatal(err)
7373
}
74-
fmt.Println("\u2713 Supported cli version is ", currentCliVersion)
7574

76-
if currentHugoVersion == getHugoVersion() {
75+
if chompVersion(currentHugoVersion) == chompVersion(getHugoVersion()) {
7776
color.Green("\u2713 Hugo version %s is okay", getHugoVersion())
7877
} else {
7978
color.Red("\u2717 Hugo version %s is incompatible.", getHugoVersion())
8079
color.Red("Supported Version is: %s", currentHugoVersion)
8180
}
8281

83-
if currentThemeVersion == getThemeVersion() {
82+
if chompVersion(currentThemeVersion) == chompVersion(getThemeVersion()) {
8483
color.Green("\u2713 Theme version %s is okay", getThemeVersion())
8584
} else {
8685
color.Red("\u2717 Theme version %s is incompatible.", getThemeVersion())
@@ -144,3 +143,10 @@ func checkGit() {
144143
fmt.Println("\u2713 git is installed")
145144
}
146145
}
146+
147+
func compareVersion(currentVersion string, localVersion string) bool {
148+
if chompVersion(currentVersion) == chompVersion(localVersion) {
149+
return true
150+
}
151+
return false
152+
}

commands/version.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func getHugoVersion() (hugoVersion string) {
5555
log.Fatal(err)
5656
}
5757
s := string(out[:])
58-
re := regexp.MustCompile("v....")
58+
re := regexp.MustCompile("([0-9]\\.)\\w+")
5959
hugoVersion = re.FindString(s)
6060
return
6161
}
@@ -76,6 +76,10 @@ func getCliVersion() (cliVersion string) {
7676
return Version
7777
}
7878

79+
func chompVersion(version string) string {
80+
return regexp.MustCompile("([0-9]\\.)\\w+").FindString(version)
81+
}
82+
7983
// Theme represents the currently installed devopsdays-theme Hugo theme.
8084
// The field Version represents the current version.
8185
type Theme struct {

0 commit comments

Comments
 (0)