From 1cb03135b745675e614b0b89ab3fde412276fec1 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 26 Aug 2015 18:03:30 +0800 Subject: new repo git hooks UI --- modules/git/hooks.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/git/hooks.go') diff --git a/modules/git/hooks.go b/modules/git/hooks.go index 5b3c88a9..6a1e09a9 100644 --- a/modules/git/hooks.go +++ b/modules/git/hooks.go @@ -10,6 +10,8 @@ import ( "os" "path" "strings" + + "github.com/Unknwon/com" ) // hookNames is a list of Git hooks' name that are supported. @@ -81,7 +83,10 @@ func (h *Hook) Name() string { // Update updates hook settings. func (h *Hook) Update() error { if len(strings.TrimSpace(h.Content)) == 0 { - return os.Remove(h.path) + if com.IsExist(h.path) { + return os.Remove(h.path) + } + return nil } return ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm) } -- cgit v1.2.3