]> source.dussan.org Git - gitea.git/commitdiff
small cache when get user id on interation (#29296)
authorLunny Xiao <xiaolunwen@gmail.com>
Thu, 22 Feb 2024 05:31:37 +0000 (13:31 +0800)
committerGitHub <noreply@github.com>
Thu, 22 Feb 2024 05:31:37 +0000 (13:31 +0800)
services/agit/agit.go

index bc68372570402634696acd2378b745365e052922..75b561581d51a0d897c2b674a386c0c9529bde36 100644 (file)
@@ -38,6 +38,11 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
        _, forcePush = opts.GitPushOptions["force-push"]
        objectFormat, _ := gitRepo.GetObjectFormat()
 
+       pusher, err := user_model.GetUserByID(ctx, opts.UserID)
+       if err != nil {
+               return nil, fmt.Errorf("Failed to get user. Error: %w", err)
+       }
+
        for i := range opts.OldCommitIDs {
                if opts.NewCommitIDs[i] == objectFormat.EmptyObjectID().String() {
                        results = append(results, private.HookProcReceiveRefResult{
@@ -116,11 +121,6 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
                                description = opts.GitPushOptions["description"]
                        }
 
-                       pusher, err := user_model.GetUserByID(ctx, opts.UserID)
-                       if err != nil {
-                               return nil, fmt.Errorf("Failed to get user. Error: %w", err)
-                       }
-
                        prIssue := &issues_model.Issue{
                                RepoID:   repo.ID,
                                Title:    title,