]> source.dussan.org Git - gitea.git/commitdiff
Fix incorrect notification commit url (#21479) (#21483)
authorwxiaoguang <wxiaoguang@gmail.com>
Tue, 18 Oct 2022 07:46:13 +0000 (15:46 +0800)
committerGitHub <noreply@github.com>
Tue, 18 Oct 2022 07:46:13 +0000 (15:46 +0800)
Backport #21479

For normal commits the notification url was wrong because oldCommitID is
received from the shrinked commits list.

This PR moves the commits list shrinking after the oldCommitID
assignment.

services/repository/push.go

index 65ac7b660c5f05a81a257f1482b2d69701711af5..561f6acdd8332750959384dbec52ac96c038fa91 100644 (file)
@@ -220,10 +220,6 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
                                        log.Error("updateIssuesCommit: %v", err)
                                }
 
-                               if len(commits.Commits) > setting.UI.FeedMaxCommitNum {
-                                       commits.Commits = commits.Commits[:setting.UI.FeedMaxCommitNum]
-                               }
-
                                oldCommitID := opts.OldCommitID
                                if oldCommitID == git.EmptySHA && len(commits.Commits) > 0 {
                                        oldCommit, err := gitRepo.GetCommit(commits.Commits[len(commits.Commits)-1].Sha1)
@@ -251,6 +247,10 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
                                        commits.CompareURL = ""
                                }
 
+                               if len(commits.Commits) > setting.UI.FeedMaxCommitNum {
+                                       commits.Commits = commits.Commits[:setting.UI.FeedMaxCommitNum]
+                               }
+
                                notification.NotifyPushCommits(pusher, repo, opts, commits)
 
                                if err = git_model.RemoveDeletedBranchByName(repo.ID, branch); err != nil {