can't evaluate field Extension in type string
apfohl opened this issue ยท 1 comments
apfohl commented
๐ง Summary
When running lefthook install
the hook.tmpl
can not be generated due to this error:
panic: template: hook.tmpl:50:69: executing "hook.tmpl" at <.Extension>: can't evaluate field Extension in type string
goroutine 1 [running]:
github.com/evilmartians/lefthook/internal/templates.Hook({0x7f9f21, 0xa}, {{0x0, 0x0}, 0x0, {0xc0002a8af0, 0x1, 0x1}})
/home/andreas/code/lefthook/internal/templates/templates.go:41 +0x1d3
github.com/evilmartians/lefthook/internal/lefthook.(*Lefthook).addHook(0xc00002dad0, {0x7f9f21, 0xa}, {{0x0, 0x0}, 0x0, {0xc0002a8af0, 0x1, 0x1}})
/home/andreas/code/lefthook/internal/lefthook/lefthook.go:124 +0xe7
github.com/evilmartians/lefthook/internal/lefthook.(*Lefthook).createHooksIfNeeded(0xc00002dad0, 0xc000000240, 0x40?, 0x0)
/home/andreas/code/lefthook/internal/lefthook/install.go:199 +0x6a8
github.com/evilmartians/lefthook/internal/lefthook.(*Lefthook).Install(0xc00002dad0, 0x0)
/home/andreas/code/lefthook/internal/lefthook/install.go:74 +0x1b5
github.com/evilmartians/lefthook/internal/lefthook.Install(0x0?, 0x0)
/home/andreas/code/lefthook/internal/lefthook/install.go:45 +0x32
github.com/evilmartians/lefthook/cmd.newInstallCmd.func1(0xc0000e0700?, {0xbdcc00?, 0x4?, 0x7f7639?})
/home/andreas/code/lefthook/cmd/install.go:19 +0x1e
github.com/spf13/cobra.(*Command).execute(0xc0001a2908, {0xbdcc00, 0x0, 0x0})
/home/andreas/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001a2008)
/home/andreas/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/home/andreas/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/evilmartians/lefthook/cmd.Lefthook()
/home/andreas/code/lefthook/cmd/lefthook.go:8 +0x1c
main.main()
/home/andreas/code/lefthook/main.go:10 +0x13
Lefthook version
1.7.0
Steps to reproduce
Running lefthook install
on my Ubuntu 22.04 system in the OpenProject repository.
Expected results
It should install the hooks.
Actual results
See error message above.
Possible Solution
Replace .Extension
in hook.tmpl
with $extension
below range
call.
Logs / Screenshots
โ [lefthook] cmd: [git rev-parse --show-toplevel]
โ [lefthook] err: <nil>
โ [lefthook] out: /home/andreas/code/openproject
โ [lefthook] cmd: [git rev-parse --git-path hooks]
โ [lefthook] err: <nil>
โ [lefthook] out: .git/hooks
โ [lefthook] cmd: [git rev-parse --git-path info]
โ [lefthook] err: <nil>
โ [lefthook] out: .git/info
โ [lefthook] cmd: [git rev-parse --git-dir]
โ [lefthook] err: <nil>
โ [lefthook] out: .git
โ [lefthook] cmd: [git hash-object -t tree /dev/null]
โ [lefthook] err: <nil>
โ [lefthook] out: 4b825dc642cb6eb9a060e54bf8d69288fbee4904
โ Searching config in:/home/andreas/code/openproject
mrexox commented
Thank you for capturing this issue! Will release the fix ASAP