[BUG] Correct changed files for codeowners
- The CODEOWNER feature relies on the changed files to determine which reviewers should be added according to the `CODEOWNER` file. - The current approach was to 'diff' between the base and head branch, which seems logical but fail in practice when the pull request is out of date with the base branch. Therefore it should instead diff between the head branch and the merge base of the head and base branch, so only the actual affected files by the pull requests are used, the same approach is used by the diff of an unmerged pull request. - Add integration testing (for the feature as well). - Resolves #2458
This commit is contained in:
parent
b678123de8
commit
fb2795b5bb
2 changed files with 126 additions and 1 deletions
|
@ -922,7 +922,14 @@ func PullRequestCodeOwnersReview(ctx context.Context, pull *Issue, pr *PullReque
|
|||
}
|
||||
|
||||
rules, _ := GetCodeOwnersFromContent(ctx, data)
|
||||
changedFiles, err := repo.GetFilesChangedBetween(git.BranchPrefix+pr.BaseBranch, pr.GetGitRefName())
|
||||
|
||||
prInfo, err := repo.GetCompareInfo(repo.Path, git.BranchPrefix+pr.BaseBranch, pr.GetGitRefName(), false, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Use the merge base as the base instead of the main branch to avoid problems
|
||||
// if the pull request is out of date with the base branch.
|
||||
changedFiles, err := repo.GetFilesChangedBetween(prInfo.MergeBase, pr.HeadCommitID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue