1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-03 09:07:19 +00:00

Performance optimization for git push (#30104) (#30354)

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`.

Backport #30104
This commit is contained in:
Lunny Xiao
2024-04-10 14:12:19 +08:00
committed by GitHub
parent 3f6ddd9bee
commit 6e3aaa9975
5 changed files with 166 additions and 74 deletions

View File

@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
)
// Git environment variables
@ -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) util.OptionalBool {
if val, ok := g[key]; ok {
if b, err := strconv.ParseBool(val); err == nil {
return b
return util.OptionalBoolOf(b)
}
}
return def
return util.OptionalBoolNone
}
// 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