diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/hook.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/hook.go b/cmd/hook.go index 6e31710caf..e8a8b1f4ad 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -290,8 +290,22 @@ Gitea or set your environment appropriately.`, "") return nil } +// runHookUpdate avoid to do heavy operations on update hook because it will be +// invoked for every ref update which does not like pre-receive and post-receive func runHookUpdate(c *cli.Context) error { + if isInternal, _ := strconv.ParseBool(os.Getenv(repo_module.EnvIsInternal)); isInternal { + return nil + } + // Update is empty and is kept only for backwards compatibility + if len(os.Args) < 3 { + return nil + } + refName := git.RefName(os.Args[len(os.Args)-3]) + if refName.IsPull() { + // ignore update to refs/pull/xxx/head, so we don't need to output any information + os.Exit(1) + } return nil } |