Skip to content

Commit

Permalink
fix: Bring back auto install (#286)
Browse files Browse the repository at this point in the history
* fix: Bring back auto install

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>

* fix: Run prepare-commig-msg hook but with limited logging

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>
  • Loading branch information
mrexox authored Jun 24, 2022
1 parent a9ef7a1 commit 8225573
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions internal/lefthook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func (l *Lefthook) Run(hookName string, gitArgs []string) error {
return nil
}

if hookName == config.ChecksumHookName {
log.SetLevel(log.WarnLevel)
}

// Load config
cfg, err := config.Load(l.Fs, l.repo.RootPath)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/templates/hook.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh

{{.AutoInstall}}

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi
Expand All @@ -10,12 +8,12 @@ if [ -t 1 ] ; then
exec < /dev/tty ; # <- enables interactive shell
fi

dir="$(git rev-parse --show-toplevel)"
osArch=$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')
cpuArch=$(echo "$(uname -m)" | sed 's/aarch64/arm64/')

call_lefthook()
{
dir="$(git rev-parse --show-toplevel)"
osArch=$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')
cpuArch=$(echo "$(uname -m)" | sed 's/aarch64/arm64/')

if lefthook{{.Extension}} -h >/dev/null 2>&1
then
eval lefthook{{.Extension}} $@
Expand All @@ -42,4 +40,6 @@ call_lefthook()
fi
}

{{.AutoInstall}}

call_lefthook "run {{.HookName}} $@"
2 changes: 1 addition & 1 deletion internal/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/evilmartians/lefthook/internal/config"
)

const checksumFormat = "# lefthook_version: %s"
const checksumFormat = "# lefthook_version: %s\n\ncall_lefthook \"install\""

//go:embed *
var templatesFS embed.FS
Expand Down

0 comments on commit 8225573

Please sign in to comment.