Skip to content

Commit

Permalink
fix: Guard update to v3 (#164)
Browse files Browse the repository at this point in the history
Update-NoSkip: true
Update-Info: That is the last version for major `v2`. To update to `v3`, uninstall Githooks and install the new version.
  • Loading branch information
gabyx authored Apr 21, 2024
1 parent 116356a commit 0909543
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions githooks/cmd/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
strs "github.com/gabyx/githooks/githooks/strings"
"github.com/gabyx/githooks/githooks/updates"
"github.com/gabyx/githooks/githooks/updates/download"
"github.com/hashicorp/go-version"

"github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -448,6 +449,13 @@ func runInstallDispatched(
if doUpdate {
tag = status.UpdateTag
commit = status.UpdateCommitSHA

maxVersion, _ := version.NewSemver("3.0.0")
if status.UpdateVersion.GreaterThanOrEqual(maxVersion) {
return false, cm.Error("Cannot update to version v3 and greater.\n" +
"To much changed. Uninstall Githooks completely and reinstall the new version.")
}

} else {
tag = status.LocalTag
commit = status.LocalCommitSHA
Expand Down

0 comments on commit 0909543

Please sign in to comment.