Skip to content

Commit 44a76a1

Browse files
committed
fix: using rev-parse to git dir
1 parent 5be92fc commit 44a76a1

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

examples/.gh.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/.ghc.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 1
2+
name: template-go
3+
description: This is a template for a Go project.
4+
hooks:
5+
pre-commit:
6+
- make test
7+
- make lint

pkg/hooks/hooks.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@ var hookTemplate = "#!/usr/bin/env -S sh -c 'ghc -c %s -r %s'"
1515

1616
// Path returns the path of the hook
1717
func Path(ctx context.Context) (string, error) {
18-
cwd, err := os.Getwd()
19-
if err != nil {
20-
return "", err
21-
}
22-
23-
cmd := exec.CommandContext(ctx, "git", "config", "core.hooksPath")
18+
cmd := exec.Command("git", "rev-parse", "--git-dir")
2419
out, err := cmd.Output()
2520
if err != nil {
2621
return "", err
2722
}
2823

29-
return filepath.Clean(filepath.Join(cwd, strings.TrimSuffix(conv.String(out), "\n"))), nil
24+
return strings.TrimSuffix(conv.String(out), "\n"), nil
3025
}
3126

3227
// Install installs the hook

0 commit comments

Comments
 (0)