From e646c885a380ded80f2231793f74a360d37b31aa Mon Sep 17 00:00:00 2001 From: f440 Date: Wed, 13 Nov 2019 19:27:27 +0900 Subject: [PATCH] Add support for git-worktree --- cmd/add.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/add.go b/cmd/add.go index ca1a91c7..68e7cf8c 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -3,6 +3,7 @@ package cmd import ( "io/ioutil" "log" + "os/exec" "path/filepath" "strings" @@ -138,7 +139,15 @@ func addLocalHookDir(hookName string, fs afero.Fs) { } func getGitHooksDir() string { - return filepath.Join(getRootPath(), gitHooksDir) + cmd := exec.Command("sh", "-c", "git rev-parse --git-common-dir") + + outputBytes, err := cmd.CombinedOutput() + if err != nil { + panic(err) + } + + gitDir := strings.TrimSpace(string(outputBytes)) + return filepath.Join(gitDir, "hooks") } func isLefthookFile(pathFile string) bool {