Skip to content

Commit

Permalink
Add support for git-worktree
Browse files Browse the repository at this point in the history
  • Loading branch information
f440 committed Nov 13, 2019
1 parent 6c49bb0 commit e646c88
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"io/ioutil"
"log"
"os/exec"
"path/filepath"
"strings"

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e646c88

Please sign in to comment.