From 4a08d574cf496268b5ceae4fc605e103c870d204 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 3 Nov 2019 02:31:29 +0800 Subject: [PATCH] fix 500 when edit hook (#8782) (#8790) --- modules/git/hook.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/git/hook.go b/modules/git/hook.go index 18c00b583..8f72f73f9 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