This issue serves as an umbrella issue for the following features:
gitlab-org/gitlab-ce#18627 Allow specifying protected branches using wildcards
gitlab-org/gitlab-ce#18193 Add "developers can merge" as an option for protected branches
gitlab-org/gitlab-ce#18193 Add "no one can push" as an option for protected branches
#674 (closed) Restrict pushes / merges (separately) to specific people
#675 (closed) Restrict pushes / merges (separately) to specific groups
#720 Add support for branch level read permissions
Description including problem, use cases, benefits, and/or goals
Some projects have complex requirements in terms of deployments and pushing code. To still be able to use git easily as a team, but not run the risk of accidentally making changes on a branch you shouldn't, you can use protected branches.
However, manually changing every branch to protected can be a lot of work and prevents automation and quick shipping, while maintaining this security. Therefore we want to be able to
Automatically protect branches based on certain wildcards
Restrict push access to these branches for specific people (groups or single users)
old proposal
The ability to create rules for protecting branches (1) and to restrict push access to certain people (2).
A rule should consist of one or two things:
A rule based on when a branch should be protected: production/* or production or production/the-real-thing. This should allow for * wildcards or just a branch name. Other examples: *-stable, *-stable. Restrict wildcard use to edges if necessary.
A user or group. If none is used, normal rules for protected branches are applied. If a user or group is added, pushing should ONLY be allowed by these people. This can be anyone*.
When setting a rule for a group
any group can be set
the group should automatically have this project shared with it (using the 'share with group' feature)
should be communicated in the UI
When setting a rule for a person
the person should be added to the project with master level access
this should be communicated in the UI
old issue
Something like:
allow wildcard for protected branches
allow per-user permission to protected branches.
some other feature
So people who used protected branches feature in CE can continue use it in EE but with more flexibility.
Gerrit allows per branch permissions. The customer uses this feature but would like to switch entirely to GitLab. They use a similar release branching strategy to GitLab. Each release has a release manager, or release team, that is responsible for that release branch going forward. Patches should only be approved by the release team so they want the ability to set these permissions on a branch directly.
I'm resistant to setting permission per branch, although I can see a future where we add more granular permissions to protected branches. Their use case is definitely interesting and understandable.
We will not be doing this in the next couple of releases (simply because of capacity), but after that I think we can spend some time exploring this.
@JobV we last significant deals because of this. I hear people being enthusiastic about this feature in Bitbucket. I think we should have it even though it is a lot of work. /cc @dzaporozhets
@sytses@JobV I want to avoid having two similar features (protected branches and per-branch permissions) so I propose we do this as advance to existing protected branches feature.
Something like:
allow wildcard for protected branches
allow per-user permission to protected branches.
some other feature
So people who used protected branches feature in CE can continue use it in EE but with more flexibility.
@jschatz1 Who can work on a mockup/prototype for the merged protected branch and branches pages, and the new branch permission UI? Then backend can work on it, and that frontend dev can implement the frontend part.
@jschatz1 Overall, I like it! Thinking as a new user, I'm a little confused about the difference between rules and protected branches. There's also a feeling of disconnect between the top form and protected branches on the bottom (with rules in between). I'm not sure of a better suggestion, though.
It might be better if we blur the distinction between "rules" and protected branches, and have these three broad goals (with each possibly being a separate MR):
Allow protecting branches both by explicit branch name (current behavior) and wildcard branch name
Allow restricting access to a protected branch to a specific list of users
Allow restricting access to a protected branch to a specific list of groups
This way, there's no distinction between "Rules" and "Protected Branches", and this should serve to keep the backend simpler, as well.
I'm not sure if goes against what everyone here has in mind for this feature...please let me know if this is a bad idea, for whatever reason.
Regarding an estimate for completion:
I haven't dived into the parts of the codebase that are directly git-related yet, so I'll need some time to get acquainted with this portion of the codebase.
The actual implementation seems straightforward to me; I'll have more after I've looked at the existing code.
@timothyandrew I agree that we do not need the distinction between Rules and Protected Branches, as this would only be confusing to users. Bitbucket doesn't have this distinction either.
As Protected Branches are in CE, I would suggest adding wildcard protected branches to CE, and the user/group restriction feature to EE, so that the implementations between CE and EE won't need to differ too much. Also note that an issue and MR already exist in CE to add that wildcard/regex feature: https://gitlab.com/gitlab-org/gitlab-ce/issues/5977https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3936. The MR was closed because of this issue, but that doesn't make sense if this would be EE only, while that would be community contributed and go into CE.
@JobV I agree, and I think @timothyandrew can start on the first 3 CE steps right now.
As for the UI, we can forget about the "Rules" table.
We need to change the third column in the "Already Protected" table. It is currently "Developers can push" with checkboxes in the different rows, but should become "Who can push" with "Developers", "Masters", "Nobody" as options, and later in EE, specific users or groups. Adding a separate restriction for "Who can merge" is a different problem.
Second, there would be a way to change the protection of a branch between these options. Potentially inline in the table row, although that may not scale. The backend can be implemented before that is finalized, though.
@JobV: I like the five-fold feature split - I'll get them all linked to relevant issues (edit: this is done; the new issues are in this issue's description), and we can treat this one as an umbrella issue.
@tauriedavis @alfredo1: Here's a quick look at where things stand with the frontend for protected branches. Let me know if you need any more context on any of these points.
Two features (wildcards for protected branches, allow developers to merge [but not push]) have been merged in.
Here's what the Protected Branches page looks like on master currently:
The final CE feature (allow "no one can push" as a setting for a protected branch) is in the final stages of review, and should be merged soon (gitlab-org/gitlab-ce!5081). This feature changes the UI to be more consistent with @JobV's mockup:
I'm working on the first EE-only feature (restrict branch protection to specific people). This changes the UI further due to the need for having more than one access level selected at a time. Here are screenshots of my current (rudimentary) implementation:
Thanks for the recap @timothyandrew! It was super helpful for making these mockups.
The current design looks good and matches a lot of the other settings pages. I think over time, we can work on the other settings pages so there is more distinction between sections on any given page. I've made some changes in hopes of improving the hierarchy for the protected branches now though.
CE Protected Branches
EE Protected Branches
Create:
Edit:
These updated mockups are designed more similarly to how you would add users to a project. For EE, the edit functionality remains on the same page. I also reversed the order of "# role and # users" so it mimics the select dropdown.
Basically, disable certain options in "Allowed to Merge" based on the current selection in "Allowed to Push". For example, if "Allowed to Push" is set to "Developers", developers will be able to merge even if "Allowed to Merge" is set to "Masters" (since pushes are a superset of merges).
I see, if I understand correctly, I would say the order of the permissions should be switched in the UI. Allowed to push should come first in the UI and when a role/user is added to allowed to push, they would automatically be added to allowed to merge. Does this make sense? @timothyandrew
@tauriedavis how exactly this dropdown will behave?
I understand is a dropdown but the help text says the user will be able to write a custom entry. Can you please provide a mockup showing how the dropdown/input works?
@alfredo1 The current protected branch dropdown allows creating a custom wildcard entry. This should work as an example. Although, it can probably be improved a bit - it wasn't 100% clear to me the first time I saw it.
A couple of questions for you (sorry for this long list, I didn't expect it to be that big):
When editing a protected branch (CE/EE), which expands a section below the row containing the branch name, can we highlight this row somehow?
Again when editing a protected branch (CE/EE), we do have a Save button, but the Cancel action can only be done via the Collapse/Expand symbol. What do you think of having a Cancel button?
Again when editing a protected branch (EE only), we display an input field and list inside this field all the groups/users that have the rights to merge or push. What happens when we have, say, 24 people in this input field? Does the input field expand? Do we have to use the keys on the keyboard to navigate to and remove someone specifically? We need to take this case in consideration also.
When listing groups, do you think it would bring value to indicate the number of people in each group, so we can measure the impact this decision will have (we might think twice before applying a protection to a group that has 234 developers)?
Performance wise, will displaying avatars in the dropdowns affect the rendering of the dropdown? Consider the use case of having 500 developers in a given account. We surely have this use case with some of our customers. Perhaps even much more. A front-end engineer can surely help us answer this question.
I feel Push privileges should be listed before Merge in the tables.
Should we use the "lock metaphor" on this page as well - a visual metaphor we use already to indicate that a branch/file is protected?
Could you provide a blank state for this page as well?
As per the discussion on slack regarding making the UI of the EE version match the CE version, we have decided to move away from the expand/collapse interface. Instead, the EE version will match the design of the CE version, by having a drop down for allowed to push and allowed to merge. The user will be able to select multiple roles and users from this drop down and selected users/roles should be seen at the top of the dropdown.
@regisF All great questions! Some of them aren't relevant anymore with the design change above.
When editing a protected branch (CE/EE), which expands a section below the row containing the branch name, can we highlight this row somehow?
This is a good idea, but we won’t be doing the expanding section any more.
Again when editing a protected branch (CE/EE), we do have a Save button, but the Cancel action can only be done via the Collapse/Expand symbol. What do you think of having a Cancel button?
Also a good idea, but we won’t be doing the expanding section any more.
Again when editing a protected branch (EE only), we display an input field and list inside this field all the groups/users that have the rights to merge or push. What happens when we have, say, 24 people in this input field? Does the input field expand? Do we have to use the keys on the keyboard to navigate to and remove someone specifically? We need to take this case in consideration also.
The idea was that the field would expand. You could use your cursor or keyboard to navigate and remove someone. We wont be doing this anymore, however.
When listing groups, do you think it would bring value to indicate the number of people in each group, so we can measure the impact this decision will have (we might think twice before applying a protection to a group that has 234 developers)?
Yes, I think this is a great idea! Added to mockup above.
Performance wise, will displaying avatars in the dropdowns affect the rendering of the dropdown? Consider the use case of having 500 developers in a given account. We surely have this use case with some of our customers. Perhaps even much more. A front-end engineer can surely help us answer this question.
I dont think it should have an affect. We currently render the avatars in many dropdowns throughout the site.
I feel Push privileges should be listed before Merge in the tables.
@timothyandrew I refactored the code on this view. With my changes this will be relatively easy to implement. I only need to get the right data for each dropdown. I'll create a WIP MR with my progress. So maybe you can help me with the data.
@tauriedavis Is it ok to show No matching results when filtering on the branch dropdown? Since this is actually done by the dropdown. I'm asking because in the proposed design there's no message.
@alfredo1 I removed it from the mockup because you didn't see the create wildcard button originally. But I think it is okay to show the No matching results message. The updated design/copy makes it look more obvious to me and your screenshot matches how we handle this same interaction for adding new labels.
@timothyandrewhttps://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5652 is ready, and since the EE side of this feature requires additional data I'm wondering if you can help me with that. Currently the dropdown on both CE/EE have the same kind of data. But on EE should also have users as options.
It would be great if you can provide me with the right data for each dropdown type.
@alfredo1 !581 (merged) is still in review, so we can't have users in there until that's done. Would it be easier for you if I remove all frontend code from !581 (merged), so you don't have any rework?
(edit: as an alternative, maybe you can "take over" that MR once it has been reviewed)
I see, if I understand correctly, I would say the order of the permissions should be switched in the UI. Allowed to push should come first in the UI and when a role/user is added to allowed to push, they would automatically be added to allowed to merge. Does this make sense? ( https://gitlab.com/gitlab-org/gitlab-ee/issues/179#note_13439287 )
@alfredo1: This behavior needs to be implemented as well, right? Let me know if there's any changes you need in the backend to support this.