diff options
author | Unknwon <u@gogs.io> | 2017-07-27 16:53:02 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-07-27 16:53:02 -0400 |
commit | 6bc11c44504135b232605c932c519901a680d4e1 (patch) | |
tree | e12a8d108ef2d00347a2d1789d50f61a1617cfaf /cmd | |
parent | 643c85e9c8fd237912652d14a0535dfddf614d2b (diff) |
hook: fix email not sent after push (#4430)
Turns out mail service was not initialized at all, also mail must
be sent in sync in hook mode before program exits.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/hook.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/hook.go b/cmd/hook.go index 0ff4a1c6..f8b96970 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -11,6 +11,7 @@ import ( "fmt" "os" "os/exec" + "path" "path/filepath" "strings" @@ -22,7 +23,9 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/pkg/httplib" + "github.com/gogits/gogs/pkg/mailer" "github.com/gogits/gogs/pkg/setting" + "github.com/gogits/gogs/pkg/template" http "github.com/gogits/gogs/routes/repo" ) @@ -184,6 +187,13 @@ func runHookPostReceive(c *cli.Context) error { } setup(c, "hooks/post-receive.log", true) + // Post-receive hook does more than just gather Git information, + // so we need to setup additional services for email notifications. + setting.NewPostReceiveHookServices() + mailer.NewContext() + mailer.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"), + path.Join(setting.CustomPath, "templates/mail"), template.NewFuncMap()) + isWiki := strings.Contains(os.Getenv(http.ENV_REPO_CUSTOM_HOOKS_PATH), ".wiki.git/") buf := bytes.NewBuffer(nil) |