Refactor adding groups to project features
When working on Selected groups are not persisted for allowed to merge / allowed to push and merge sections bugs, we realised that the bug originated from a wrong API call for groups. Trying to fix it by fetching groups with project aspect, we ran into another inconsistency:
-
using
Api.projectGroups
got us all the groups with project access, including the group that owns that project. However, it did fail the validation when creating the branch protection because:
@jwoodwardgl: I think this is correct. Only invited groups can be used, all the members in the project's group are already inherited members so we can give developers access by selecting the
Developers + Maintainers
role.When granting a group Allowed to merge or Allowed to push and merge permissions on a protected branch, the group must be added to the project. here link to the discussion
- in Project Settings/Repository/Protected branches we use a different endpoint to get groups with the project access. The response differs from the other one only by the owning group.
The set of groups is almost identical, but we still need to accommodate a shared component to using different endpoints, even when that component is used multiple times on one page (see Branch rules details page that encompasses protected branches and MR approval rules).