summaryrefslogtreecommitdiffstats
path: root/cmd/serv.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-02-03 14:00:48 +0000
committerGitHub <noreply@github.com>2019-02-03 14:00:48 +0000
commit13c0f7dfffc99c58c1c53f3bc0c6eaf17c3860f8 (patch)
tree49b74b20352b9e4098447c55c599e1c1cbed8abd /cmd/serv.go
parent2902b3a68c95ddc9bfe9963031ae3454a5bb7d29 (diff)
downloadgitea-13c0f7dfffc99c58c1c53f3bc0c6eaf17c3860f8.tar.gz
gitea-13c0f7dfffc99c58c1c53f3bc0c6eaf17c3860f8.zip
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
Diffstat (limited to 'cmd/serv.go')
-rw-r--r--cmd/serv.go6
1 files changed, 6 insertions, 0 deletions
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 {