Allow deletion of protected branches
Allow masters, owners & admins to delete protected branches.
In the Branches page
- Add a
Deletetooltip to the all of the Delete buttons
- For Master users (which also includes Owners and Admins), enable the Delete buttons for protected branches
- When pressing the Delete button for a protected branch, show the following confirmation modal:
# Delete protected branch ‘feature/new-awesome-feature’? You’re about to permanently delete the protected branch **feature/new-awesome-feature**. This branch hasn’t been merged yet. To avoid data loss, consider merging this branch into another before deleting it. Once you confirm and press **Delete protected branch**, it cannot be undone or recovered. To confirm, type <kbd>feature/new-awesome-feature</kbd> Cancel | Delete protected branch
- For non-Master users (Guests, Reporters or Developers), to give them some info on why the Delete button is disabled for them, add a tooltip to that button:
Only a project master or owner can delete a protected branch
Deleting a protected branch is only allowed via the web interface, not via Git. This means that people can't accidentally delete protected branches.
In Git, return the following message when attempting to delete a protected branch:
- For masters/owners/admins:
To delete a protected branch, use the web interface.
- For non-master users (guests/reporters/developers):
Only a project master or owner can delete a protected branch.
Links / references
Deleting a protected branch
From time to time, it may be required to delete or clean up branches that are protected. In older versions of GitLab, this was only possible by removing the protection, deleting the branch and then manually re-enabling it. Not only was this cumbersome, but also allowed pushing to branches that should have been protected during this manual process.
Owners and admins can now manually delete protected branches by visiting the Repository Branches and clicking on the delete icon. In order to prevent accidental deletion of protected branches, an additional confirmation is required.
With the past releases for GitLab the capability of protecting several branches by wildcard has been introduced.
Unfortunately, even for a
master user, there is no way to delete a branch that is protected under wildcard even if the branch is not longer needed, forcing the removal of the wildcard for the removal of the branch. This opens to possible issues with the other branches that are protected under that wildcard.
To remove the branch release-v-1.0.0 you are now required to remove the wildcard release-v-* which will automatically make the other 2 release branches unprotected.
Add the functionality of unprotecting a protected branch by wildcard as long as the user is a
administrator level user (not developer role). So the clean up of past protected branches can be done.