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 /services/agit | |
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 'services/agit')
-rw-r--r-- | services/agit/agit.go | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/services/agit/agit.go b/services/agit/agit.go index eb3bafa906..52a70469e0 100644 --- a/services/agit/agit.go +++ b/services/agit/agit.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/private" + "code.gitea.io/gitea/modules/setting" notify_service "code.gitea.io/gitea/services/notify" pull_service "code.gitea.io/gitea/services/pull" ) @@ -145,10 +146,14 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. log.Trace("Pull request created: %d/%d", repo.ID, prIssue.ID) results = append(results, private.HookProcReceiveRefResult{ - Ref: pr.GetGitRefName(), - OriginalRef: opts.RefFullNames[i], - OldOID: objectFormat.EmptyObjectID().String(), - NewOID: opts.NewCommitIDs[i], + Ref: pr.GetGitRefName(), + OriginalRef: opts.RefFullNames[i], + OldOID: objectFormat.EmptyObjectID().String(), + NewOID: opts.NewCommitIDs[i], + IsCreatePR: true, + URL: fmt.Sprintf("%s/pulls/%d", repo.HTMLURL(), pr.Index), + ShouldShowMessage: setting.Git.PullRequestPushMessage && repo.AllowsPulls(ctx), + HeadBranch: headBranch, }) continue } @@ -208,11 +213,14 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. isForcePush := comment != nil && comment.IsForcePush results = append(results, private.HookProcReceiveRefResult{ - OldOID: oldCommitID, - NewOID: opts.NewCommitIDs[i], - Ref: pr.GetGitRefName(), - OriginalRef: opts.RefFullNames[i], - IsForcePush: isForcePush, + OldOID: oldCommitID, + NewOID: opts.NewCommitIDs[i], + Ref: pr.GetGitRefName(), + OriginalRef: opts.RefFullNames[i], + IsForcePush: isForcePush, + IsCreatePR: false, + URL: fmt.Sprintf("%s/pulls/%d", repo.HTMLURL(), pr.Index), + ShouldShowMessage: setting.Git.PullRequestPushMessage && repo.AllowsPulls(ctx), }) } |