diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-04-09 11:43:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 03:43:17 +0000 |
commit | 263a716cb52037f3e7e51f014f6c8cdfad6ae03d (patch) | |
tree | 2ca921707de7f1d35bacefe0f06a9ea0aa676f32 /modules | |
parent | 72dc75e594fb5227abfa1cb74cb652cc33bacc93 (diff) | |
download | gitea-263a716cb52037f3e7e51f014f6c8cdfad6ae03d.tar.gz gitea-263a716cb52037f3e7e51f014f6c8cdfad6ae03d.zip |
Performance optimization for git push (#30104)
Agit returned result should be from `ProcReceive` hook but not
`PostReceive` hook. Then for all non-agit pull requests, it will not
check the pull requests for every pushing `refs/pull/%d/head`.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/private/hook.go | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/modules/private/hook.go b/modules/private/hook.go index cab8c81224..79c3d48229 100644 --- a/modules/private/hook.go +++ b/modules/private/hook.go @@ -11,6 +11,7 @@ import ( "time" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/optional" "code.gitea.io/gitea/modules/setting" ) @@ -32,13 +33,13 @@ const ( ) // Bool checks for a key in the map and parses as a boolean -func (g GitPushOptions) Bool(key string, def bool) bool { +func (g GitPushOptions) Bool(key string) optional.Option[bool] { if val, ok := g[key]; ok { if b, err := strconv.ParseBool(val); err == nil { - return b + return optional.Some(b) } } - return def + return optional.None[bool]() } // HookOptions represents the options for the Hook calls @@ -87,13 +88,17 @@ type HookProcReceiveResult struct { // HookProcReceiveRefResult represents an individual result from ProcReceive type HookProcReceiveRefResult struct { - OldOID string - NewOID string - Ref string - OriginalRef git.RefName - IsForcePush bool - IsNotMatched bool - Err string + OldOID string + NewOID string + Ref string + OriginalRef git.RefName + IsForcePush bool + IsNotMatched bool + Err string + IsCreatePR bool + URL string + ShouldShowMessage bool + HeadBranch string } // HookPreReceive check whether the provided commits are allowed |