Skip to content

Commit ef28111

Browse files
committed
Handle git client not present on compilation
1 parent 77b81f6 commit ef28111

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/git/path.ex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,18 @@ defmodule GitHooks.Git.Path do
4343
|> Version.compare(Version.parse!("2.10.0"))
4444
|> case do
4545
:lt ->
46-
{path, 0} = System.cmd("git", ["rev-parse", "--git-dir", dir])
47-
String.replace(path, "\n", "")
46+
"git"
47+
|> System.cmd(["rev-parse", "--git-dir", dir])
48+
|> build_git_path()
4849

4950
_gt_or_eq ->
50-
{path, 0} = System.cmd("git", ["rev-parse", "--git-path", dir])
51-
String.replace(path, "\n", "")
51+
"git"
52+
|> System.cmd(["rev-parse", "--git-path", dir])
53+
|> build_git_path()
5254
end
5355
end
56+
57+
@spec build_git_path({String.t(), number}) :: String.t()
58+
defp build_git_path({path, 0}), do: String.replace(path, "\n", "")
59+
defp build_git_path(_), do: ".git/hooks"
5460
end

0 commit comments

Comments
 (0)