• Stan Hu's avatar
    Allow overriding of project approvers in merge request · dcf38617
    Stan Hu authored
    Previously specifying blank `user_ids` and `group_ids` during the
    creation of a merge request approver rule would cause the merge request
    to inherit from the project rule. However, that prevents users from
    setting the merge request approvers to "any approver". To fix this, we
    only set the "any approver" type if `user_ids` and `group_ids` is not
    specified and no project approvers are present.
    
    In addition, this commit also fixes the approval rule type when project
    rule has users/groups.
    
    Suppose a project has an approval rule that includes specific users or
    groups as approvers. If a user attempts to create a merge request
    approval rule based on this project rule but omits `user_ids` and
    `group_ids`, previously this rule would be erroneously assigned "any
    approver". However, the project approvers should be inherited.
    
    To fix this, we:
    
    1. First copy the project approval rules.
    
    2. If the newly-modified params indicate specific users or groups, don't
    assign the merge request rule the "any approver" type.
    
    Found while investigating failures in upgrading Grape v1.3.3 in
    https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33450.
    dcf38617
sh-fix-any-approvals-with-project-rules.yml 110 Bytes