@@ -11,6 +11,7 @@ import (
11
11
"github.com/git-lfs/git-lfs/config"
12
12
"github.com/git-lfs/git-lfs/errors"
13
13
"github.com/git-lfs/git-lfs/git"
14
+ "github.com/rubyist/tracerx"
14
15
)
15
16
16
17
var (
@@ -38,7 +39,8 @@ func NewStandardHook(theType string, upgradeables []string) *Hook {
38
39
39
40
func (h * Hook ) Exists () bool {
40
41
_ , err := os .Stat (h .Path ())
41
- return err == nil
42
+
43
+ return ! os .IsNotExist (err )
42
44
}
43
45
44
46
// Path returns the desired (or actual, if installed) location where this hook
@@ -65,14 +67,18 @@ func (h *Hook) Dir() string {
65
67
// directory. It returns and halts at any errors, and returns nil if the
66
68
// operation was a success.
67
69
func (h * Hook ) Install (force bool ) error {
70
+ msg := fmt .Sprintf ("Install hook: %s, force=%t, path=%s" , h .Type , force , h .Path ())
71
+
68
72
if err := os .MkdirAll (h .Dir (), 0755 ); err != nil {
69
73
return err
70
74
}
71
75
72
76
if h .Exists () && ! force {
77
+ tracerx .Printf (msg + ", upgrading..." )
73
78
return h .Upgrade ()
74
79
}
75
80
81
+ tracerx .Printf (msg )
76
82
return h .write ()
77
83
}
78
84
@@ -107,15 +113,19 @@ func (h *Hook) Uninstall() error {
107
113
return errors .New ("Not in a git repository" )
108
114
}
109
115
116
+ msg := fmt .Sprintf ("Uninstall hook: %s, path=%s" , h .Type , h .Path ())
117
+
110
118
match , err := h .matchesCurrent ()
111
119
if err != nil {
112
120
return err
113
121
}
114
122
115
123
if ! match {
124
+ tracerx .Printf (msg + ", doesn't match..." )
116
125
return nil
117
126
}
118
127
128
+ tracerx .Printf (msg )
119
129
return os .RemoveAll (h .Path ())
120
130
}
121
131
0 commit comments