Assign approvers based on code owners
A code owners file provides a version controlled way of documenting which groups or individuals are key stakeholders in specific areas of the codebase. These people are likely to be the best people to request a code review from and would likely make the best approvers.
Code owners are now suggested as approvers https://gitlab.com/gitlab-org/gitlab-ee/issues/5382 when opening or editing a merge request. But in most instances it would be more convenient for the code owner to simply be added assigned as approver.
When creating a merge request, and when new changes are pushed, code owners should automatically be assigned as approvers if they are eligible approvers.
This behavior is enabled by default if using code owners, upgrading and automating the suggest code owners behavior.
mis the number of required approvals
Ωis the set of explicit approvers (configured in the project settings)
Cis the set of code owners for the change
The current logic is, and remains:
m <= |Ω|– then only those explicit approvers can approve the merge request
m > |Ω|– then all the explicit approvers and the members of the given project with Developer role or higher are eligible approvers of the merge request.
The definition of an explicit approver should become the union of approvers configured in project settings and code owners.
This behavior does not impose any requirements on the Can override approvers and approvals required per merge request setting.
Considerations of this approach
If a team uses merge request approvals to enforce a 2-person review from senior developers, using code owners may by of less value. Only senior developers should be added to the code owners file. This is likely already the case.