Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3e7052

Browse files
GiteaBotlunny
andauthored
Fix wrong review requests when updating the pull request (#34286) (#34304)
Backport#34286 by@lunnyFix#34224The previous implementation in#33744 will get the pushed commitschanged files. But it's not always right when push a merged commit. ThisPR reverted the logic in#33744 and will always get the PR's changedfiles and get code owners.Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parenta9d5ab8 commite3e7052

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

‎services/issue/pull.go‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ func IsCodeOwnerFile(f string) bool {
4848
}
4949

5050
funcPullRequestCodeOwnersReview(ctx context.Context,pr*issues_model.PullRequest) ([]*ReviewRequestNotifier,error) {
51-
returnPullRequestCodeOwnersReviewSpecialCommits(ctx,pr,"","")// no commit is provided, then it uses PR's base&head branch
52-
}
53-
54-
funcPullRequestCodeOwnersReviewSpecialCommits(ctx context.Context,pr*issues_model.PullRequest,startCommitID,endCommitIDstring) ([]*ReviewRequestNotifier,error) {
5551
iferr:=pr.LoadIssue(ctx);err!=nil {
5652
returnnil,err
5753
}
@@ -100,19 +96,15 @@ func PullRequestCodeOwnersReviewSpecialCommits(ctx context.Context, pr *issues_m
10096
returnnil,nil
10197
}
10298

103-
ifstartCommitID==""&&endCommitID=="" {
104-
// get the mergebase
105-
mergeBase,err:=getMergeBase(repo,pr,git.BranchPrefix+pr.BaseBranch,pr.GetGitRefName())
106-
iferr!=nil {
107-
returnnil,err
108-
}
109-
startCommitID=mergeBase
110-
endCommitID=pr.GetGitRefName()
99+
// get the mergebase
100+
mergeBase,err:=getMergeBase(repo,pr,git.BranchPrefix+pr.BaseBranch,pr.GetGitRefName())
101+
iferr!=nil {
102+
returnnil,err
111103
}
112104

113105
// https://github.com/go-gitea/gitea/issues/29763, we need to get the files changed
114106
// between the merge base and the head commit but not the base branch and the head commit
115-
changedFiles,err:=repo.GetFilesChangedBetween(startCommitID,endCommitID)
107+
changedFiles,err:=repo.GetFilesChangedBetween(mergeBase,pr.GetGitRefName())
116108
iferr!=nil {
117109
returnnil,err
118110
}
@@ -138,8 +130,23 @@ func PullRequestCodeOwnersReviewSpecialCommits(ctx context.Context, pr *issues_m
138130
returnnil,err
139131
}
140132

133+
// load all reviews from database
134+
latestReivews,_,err:=issues_model.GetReviewsByIssueID(ctx,pr.IssueID)
135+
iferr!=nil {
136+
returnnil,err
137+
}
138+
139+
contain:=func(list issues_model.ReviewList,u*user_model.User)bool {
140+
for_,review:=rangelist {
141+
ifreview.ReviewerTeamID==0&&review.ReviewerID==u.ID {
142+
returntrue
143+
}
144+
}
145+
returnfalse
146+
}
147+
141148
for_,u:=rangeuniqUsers {
142-
ifu.ID!=issue.Poster.ID {
149+
ifu.ID!=issue.Poster.ID&&!contain(latestReivews,u){
143150
comment,err:=issues_model.AddReviewRequest(ctx,issue,u,issue.Poster)
144151
iferr!=nil {
145152
log.Warn("Failed add assignee user: %s to PR review: %s#%d, error: %s",u.Name,pr.BaseRepo.Name,pr.ID,err)
@@ -155,6 +162,7 @@ func PullRequestCodeOwnersReviewSpecialCommits(ctx context.Context, pr *issues_m
155162
})
156163
}
157164
}
165+
158166
for_,t:=rangeuniqTeams {
159167
comment,err:=issues_model.AddTeamReviewRequest(ctx,issue,t,issue.Poster)
160168
iferr!=nil {

‎services/pull/pull.go‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,7 @@ func AddTestPullRequestTask(opts TestPullRequestOptions) {
440440
}
441441

442442
if!pr.IsWorkInProgress(ctx) {
443-
varreviewNotifiers []*issue_service.ReviewRequestNotifier
444-
ifopts.IsForcePush {
445-
reviewNotifiers,err=issue_service.PullRequestCodeOwnersReview(ctx,pr)
446-
}else {
447-
reviewNotifiers,err=issue_service.PullRequestCodeOwnersReviewSpecialCommits(ctx,pr,opts.OldCommitID,opts.NewCommitID)
448-
}
443+
reviewNotifiers,err:=issue_service.PullRequestCodeOwnersReview(ctx,pr)
449444
iferr!=nil {
450445
log.Error("PullRequestCodeOwnersReview: %v",err)
451446
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp