Skip to content

Commit

Permalink
fix: more verbose error on versions mismatch (#721)
Browse files Browse the repository at this point in the history
* fix: more verbose error on versions mismatch

* fix: add lefthook path
  • Loading branch information
mrexox authored May 17, 2024
1 parent e42043f commit ce8d4f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package version

import (
"errors"
"fmt"
"os"
"regexp"
"strconv"
)
Expand All @@ -17,7 +19,6 @@ var (
)

errIncorrectVersion = errors.New("format of 'min_version' setting is incorrect")
errUncovered = errors.New("required Lefthook version is higher than current")
)

func Version(verbose bool) string {
Expand Down Expand Up @@ -49,6 +50,12 @@ func CheckCovered(targetVersion string) error {
return err
}

execPath, err := os.Executable()
if err != nil {
execPath = "<unknown>"
}
errUncovered := fmt.Errorf("required lefthook version (%s) is higher than current (%s) at %s", targetVersion, version, execPath)

switch {
case major > tMajor:
return nil
Expand Down
2 changes: 1 addition & 1 deletion testdata/min_version.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exec git init
! exec lefthook run pre-commit
stdout 'required Lefthook version is higher than current'
stdout 'required lefthook version \(13.1.1\) is higher than current'

-- lefthook.yml --
min_version: 13.1.1
Expand Down

0 comments on commit ce8d4f2

Please sign in to comment.