Skip to content

Commit

Permalink
Fix critical bug introduced with #206
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-epam authored and Eitan Joffe committed Jun 6, 2022
1 parent 9cfba23 commit 51f9f7d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions hook/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ import (
"github.com/rs/zerolog/log"
)

const (
hookPath = "hooks/commit-msg"
)
var hookPath = "hooks/commit-msg"

func InstallCommitHook(cfg *config.Config, gitcmd git.GitInterface) {
var rootdir string
err := gitcmd.Git("rev-parse --git-common-dir", &rootdir)
check(err)
rootdir = strings.TrimSpace(rootdir)

_, err = os.Stat(rootdir)
if os.IsNotExist(err) {
err = gitcmd.Git("rev-parse --show-toplevel", &rootdir)
check(err)
rootdir = strings.TrimSpace(rootdir)
hookPath = ".git/" + hookPath
}

err = os.Chdir(rootdir)
check(err)

Expand Down

0 comments on commit 51f9f7d

Please sign in to comment.