Skip to content

Commit

Permalink
Fix incorrect notification commit url (#21479) (#21483)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wxiaoguang authored Oct 18, 2022
1 parent 5a84558 commit 19df07f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 19df07f

Please sign in to comment.