@@ -11,7 +11,7 @@ defmodule GitHooks.Git.Path do
1111
1212 case { git_hooks_path_config , git_path_config } do
1313 { nil , nil } ->
14- resolve_git_hooks_path_based_on_git_version ( )
14+ resolve_git_path_based_on_git_version ( "hooks" )
1515
1616 { nil , git_path_config } ->
1717 "#{ git_path_config } /hooks"
@@ -23,7 +23,8 @@ defmodule GitHooks.Git.Path do
2323
2424 @ doc false
2525 def resolve_app_path do
26- git_dir = Application . get_env ( :git_hooks , :git_path , & resolve_git_hooks_path / 0 )
26+ git_path = resolve_git_path_based_on_git_version ( )
27+ git_dir = Application . get_env ( :git_hooks , :git_path , git_path )
2728 repo_dir = Path . dirname ( git_dir )
2829
2930 Path . relative_to ( File . cwd! ( ) , repo_dir )
@@ -48,17 +49,17 @@ defmodule GitHooks.Git.Path do
4849 # This will support as well changes on the default /hooks path:
4950 # `git config core.hooksPath .myCustomGithooks/`
5051
51- @ spec resolve_git_hooks_path_based_on_git_version ( ) :: String . t ( )
52- defp resolve_git_hooks_path_based_on_git_version ( ) do
52+ @ spec resolve_git_path_based_on_git_version ( dir :: String . t ( ) ) :: String . t ( )
53+ defp resolve_git_path_based_on_git_version ( dir \\ "" ) do
5354 Git . git_version ( )
5455 |> Version . compare ( Version . parse! ( "2.10.0" ) )
5556 |> case do
5657 :lt ->
57- { path , 0 } = System . cmd ( "git" , [ "rev-parse" , "--git-dir" , "hooks" ] )
58+ { path , 0 } = System . cmd ( "git" , [ "rev-parse" , "--git-dir" , dir ] )
5859 String . replace ( path , "\n " , "" )
5960
6061 _gt_or_eq ->
61- { path , 0 } = System . cmd ( "git" , [ "rev-parse" , "--git-path" , "hooks" ] )
62+ { path , 0 } = System . cmd ( "git" , [ "rev-parse" , "--git-path" , dir ] )
6263 String . replace ( path , "\n " , "" )
6364 end
6465 end
0 commit comments