File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,14 +49,27 @@ func (r *Repository) HookExists(hook string) bool {
4949func (r * Repository ) HooksDir () string {
5050 if r .hooksDir == "" {
5151 r .hooksDir = r .gitDir + "/hooks"
52- var hooksPath = r .ConfigValue ( "core. hooksPath" , "" )
52+ var hooksPath = r .hooksPath ( )
5353 if hooksPath != "" {
54- r .hooksDir = r . root + "/" + hooksPath
54+ r .hooksDir = hooksPath
5555 }
5656 }
5757 return r .hooksDir
5858}
5959
60+ // hooksPath returns the core.hooksPath configured path
61+ // If the path is relative it will be prefixed with the repository root
62+ func (r * Repository ) hooksPath () string {
63+ hooksPath := r .ConfigValue ("core.hooksPath" , "" )
64+ if hooksPath == "" {
65+ return ""
66+ }
67+ if path .IsAbs (hooksPath ) {
68+ return hooksPath
69+ }
70+ return r .root + "/" + hooksPath
71+ }
72+
6073func (r * Repository ) CommitMessage (path string ) (* types.CommitMessage , error ) {
6174 if path == "" {
6275 return nil , errors .New ("invalid file path" )
You can’t perform that action at this time.
0 commit comments