Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit 21aca48

Browse files
segevfinerlafriks
authored andcommitted
Update IsActive on Hook.Update (#151)
Signed-off-by: Segev Finer <[email protected]>
1 parent ec4d631 commit 21aca48

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

hook.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,20 @@ func (h *Hook) Name() string {
8282
func (h *Hook) Update() error {
8383
if len(strings.TrimSpace(h.Content)) == 0 {
8484
if isExist(h.path) {
85-
return os.Remove(h.path)
85+
err := os.Remove(h.path)
86+
if err != nil {
87+
return err
88+
}
8689
}
90+
h.IsActive = false
8791
return nil
8892
}
89-
return ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
93+
err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
94+
if err != nil {
95+
return err
96+
}
97+
h.IsActive = true
98+
return nil
9099
}
91100

92101
// ListHooks returns a list of Git hooks of given repository.

0 commit comments

Comments
 (0)