mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	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`.
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user