From 13c0f7dfffc99c58c1c53f3bc0c6eaf17c3860f8 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 3 Feb 2019 14:00:48 +0000 Subject: Fix notifications on pushing with deploy keys by setting hook environment variables (#5935) The gitea prerecieve and postrecieve hooks and the gitea PushUpdate function require that the PusherID and PusherName are real users. Previously, these environment variables were not being set when using a deploy key - the main result being that pushing to empty repositories meant that is_empty status was not changed. I've also added an integration test to ensure that the is_empty status is updated on pushing with a deploy key. There is a slight issue in that the deploy key is now considered a proxy for the owner - we don't have a way of separating out the deploy key from the owner at present. This can be fixed in another PR. Fix #3795 Signed-off-by: Andrew Thornton art27@cantab.net --- cmd/serv.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmd') diff --git a/cmd/serv.go b/cmd/serv.go index 1b65dab2b3..21a69b24d6 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -251,6 +251,12 @@ func runServ(c *cli.Context) error { if err = private.UpdateDeployKeyUpdated(key.ID, repo.ID); err != nil { fail("Internal error", "UpdateDeployKey: %v", err) } + + // FIXME: Deploy keys aren't really the owner of the repo pushing changes + // however we don't have good way of representing deploy keys in hook.go + // so for now use the owner + os.Setenv(models.EnvPusherName, username) + os.Setenv(models.EnvPusherID, fmt.Sprintf("%d", repo.OwnerID)) } else { user, err = private.GetUserByKeyID(key.ID) if err != nil { -- cgit v1.2.3