@@ -48,6 +48,10 @@ func IsCodeOwnerFile(f string) bool {
4848}
4949
5050func PullRequestCodeOwnersReview (ctx context.Context , pr * issues_model.PullRequest ) ([]* ReviewRequestNotifier , error ) {
51+ return PullRequestCodeOwnersReviewSpecialCommits (ctx , pr , "" , "" )
52+ }
53+
54+ func PullRequestCodeOwnersReviewSpecialCommits (ctx context.Context , pr * issues_model.PullRequest , startCommitID , endCommitID string ) ([]* ReviewRequestNotifier , error ) {
5155 if err := pr .LoadIssue (ctx ); err != nil {
5256 return nil , err
5357 }
@@ -78,7 +82,6 @@ func PullRequestCodeOwnersReview(ctx context.Context, pr *issues_model.PullReque
7882 }
7983
8084 var data string
81-
8285 for _ , file := range codeOwnerFiles {
8386 if blob , err := commit .GetBlobByPath (file ); err == nil {
8487 data , err = blob .GetBlobContent (setting .UI .MaxDisplayFileSize )
@@ -87,18 +90,28 @@ func PullRequestCodeOwnersReview(ctx context.Context, pr *issues_model.PullReque
8790 }
8891 }
8992 }
93+ if data == "" {
94+ return nil , nil
95+ }
9096
9197 rules , _ := issues_model .GetCodeOwnersFromContent (ctx , data )
98+ if len (rules ) == 0 {
99+ return nil , nil
100+ }
92101
93- // get the mergebase
94- mergeBase , err := getMergeBase (repo , pr , git .BranchPrefix + pr .BaseBranch , pr .GetGitRefName ())
95- if err != nil {
96- return nil , err
102+ if startCommitID == "" && endCommitID == "" {
103+ // get the mergebase
104+ mergeBase , err := getMergeBase (repo , pr , git .BranchPrefix + pr .BaseBranch , pr .GetGitRefName ())
105+ if err != nil {
106+ return nil , err
107+ }
108+ startCommitID = mergeBase
109+ endCommitID = pr .GetGitRefName ()
97110 }
98111
99112 // https://github.com/go-gitea/gitea/issues/29763, we need to get the files changed
100113 // between the merge base and the head commit but not the base branch and the head commit
101- changedFiles , err := repo .GetFilesChangedBetween (mergeBase , pr . GetGitRefName () )
114+ changedFiles , err := repo .GetFilesChangedBetween (startCommitID , endCommitID )
102115 if err != nil {
103116 return nil , err
104117 }
0 commit comments