From 21dfe1b2567f666789a09c2b38114f389ebac30d Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 2 Nov 2019 21:38:11 +0800 Subject: [PATCH] fix 500 when edit hook (#8782) --- modules/git/hook.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/git/hook.go b/modules/git/hook.go index e966591668..245c6b92ce 100644 --- a/modules/git/hook.go +++ b/modules/git/hook.go @@ -90,6 +90,11 @@ func (h *Hook) Update() error { h.IsActive = false return nil } + d := filepath.Dir(h.path) + if err := os.MkdirAll(d, os.ModePerm); err != nil { + return err + } + err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm) if err != nil { return err -- 2.39.5