Delete Merged Branches also deletes protected branches - Reintroduction of #34553
Summary
According to this bug https://gitlab.com/gitlab-org/gitlab-ce/issues/34553, hitting delete merged branches
should not delete the protected
branches without proper confirmation.
Steps to reproduce
- Create a simple project with a name that you like
- create a dev branch out of master and commit something into a readme file and add a .gitignore file
- push dev and protect the dev branch
- make dev branch default
- create a release branch out of dev branch
- add changes and push it out
- protect the release branch by adding a
release*
wildcard - create a patch branch from the release branch and push it out
- protect the patch branch by adding a
patch*
wildcard - merge release into dev
- create a random branch and add changes
- merge the random branch into dev
- go to Gitlab UI and click
delete merged branches
- All branches merged are now deleted including the
protected
ones
Example Project
This was originally noticed on a Gitlab EE installed, but, for testing sakes, I have replicated the same process on a public project.
https://gitlab.com/mcloide1977/delete-merged-branches-public/branches
What is the current bug behavior?
Whenever you click the Delete Merged Branches
it will delete all branches that are merged into the default
branch including the protected branches. The projected branches are removed without any confirmation.
On the example project, you can notice that the only branches kept are the default
branch and master
.
What is the expected correct behavior?
Protected branches should not be deleted without confirmation: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11000 and https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12624 both already mentioned at this bug: https://gitlab.com/gitlab-org/gitlab-ce/issues/34553
Relevant logs and/or screenshots
- https://www.screencast.com/t/qbikvVt2FqL
- https://www.screencast.com/t/3vY2FyYGqG
- https://www.screencast.com/t/oLQteDLqGM0D
- https://www.screencast.com/t/U2GJtn5c
- https://www.screencast.com/t/IVqH1Ks52IXp
- https://www.screencast.com/t/3EtBSV2p
Note: The example project was created on the Gitlab.com and logs should be able to be retrieved there. Same process done as our internal Gitlab EE.
Output of checks
n/a
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.3.3p222 Gem Version: 2.6.6 Bundler Version:1.13.7 Rake Version: 10.5.0 Redis Version: 3.2.5 Git Version: 2.13.0 Sidekiq Version:5.0.0 Go Version: unknown
GitLab information Version: 9.3.9-ee Revision: 7a27f14 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.3 URL: HTTP Clone URL: /some-group/some-project.git SSH Clone URL: some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: no
GitLab Shell Version: 5.1.1 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...
GitLab Shell version >= 5.1.1 ? ... OK (5.1.1) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 5/3 ... ok 5/6 ... ok 5/7 ... ok 5/8 ... ok 5/9 ... ok 5/10 ... ok 5/11 ... ok 5/12 ... ok 5/13 ... ok 5/14 ... ok 5/15 ... ok 5/16 ... ok 5/17 ... ok 5/18 ... ok 5/19 ... ok 5/20 ... ok 5/21 ... ok 5/22 ... ok 5/23 ... ok 5/24 ... ok 5/25 ... ok 5/26 ... ok 5/27 ... ok 5/28 ... ok 5/31 ... ok 5/32 ... ok 5/33 ... ok 5/35 ... ok 11/36 ... ok 11/37 ... ok 5/38 ... ok 5/39 ... ok 5/40 ... ok 5/41 ... ok 5/44 ... ok 5/45 ... ok 5/46 ... ok 5/48 ... ok 3/49 ... ok 5/50 ... ok 5/53 ... ok 5/54 ... ok 5/55 ... ok 13/57 ... ok 5/73 ... ok 5/74 ... ok 5/75 ... ok 5/76 ... ok 13/80 ... ok 5/82 ... ok 11/85 ... ok 25/86 ... ok 5/87 ... ok 5/88 ... ok 14/90 ... ok 18/91 ... ok 5/92 ... ok 14/93 ... ok 5/94 ... ok 24/95 ... ok 5/97 ... ok 24/98 ... ok 24/99 ... ok 13/100 ... ok 5/104 ... ok 5/105 ... ok 24/108 ... ok 13/120 ... ok 25/121 ... ok 25/122 ... ok 13/129 ... ok 10/130 ... ok 28/131 ... ok 25/133 ... ok 25/134 ... ok 32/135 ... repository is empty 33/136 ... repository is empty 33/137 ... repository is empty 34/138 ... repository is empty 34/139 ... repository is empty 13/140 ... ok 3/141 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Access to /var/opt/gitlab/.ssh/authorized_keys: OK Send ping to redis server: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 5/3 ... yes 5/6 ... yes 5/7 ... yes 5/8 ... yes 5/9 ... yes 5/10 ... yes 5/11 ... yes 5/12 ... yes 5/13 ... yes 5/14 ... yes 5/15 ... yes 5/16 ... yes 5/17 ... yes 5/18 ... yes 5/19 ... yes 5/20 ... yes 5/21 ... yes 5/22 ... yes 5/23 ... yes 5/24 ... yes 5/25 ... yes 5/26 ... yes 5/27 ... yes 5/28 ... yes 5/31 ... yes 5/32 ... yes 5/33 ... yes 5/35 ... yes 11/36 ... yes 11/37 ... yes 5/38 ... yes 5/39 ... yes 5/40 ... yes 5/41 ... yes 5/44 ... yes 5/45 ... yes 5/46 ... yes 5/48 ... yes 3/49 ... yes 5/50 ... yes 5/53 ... yes 5/54 ... yes 5/55 ... yes 13/57 ... yes 5/73 ... yes 5/74 ... yes 5/75 ... yes 5/76 ... yes 13/80 ... yes 5/82 ... yes 11/85 ... yes 25/86 ... yes 5/87 ... yes 5/88 ... yes 14/90 ... yes 18/91 ... yes 5/92 ... yes 14/93 ... yes 5/94 ... yes 24/95 ... yes 5/97 ... yes 24/98 ... yes 24/99 ... yes 13/100 ... yes 5/104 ... yes 5/105 ... yes 24/108 ... yes 13/120 ... yes 25/121 ... yes 25/122 ... yes 13/129 ... yes 10/130 ... yes 28/131 ... yes 25/133 ... yes 25/134 ... yes 32/135 ... yes 33/136 ... yes 33/137 ... yes 34/138 ... yes 34/139 ... yes 13/140 ... yes 3/141 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... yes (2.3.3) Git version >= 2.7.3 ? ... yes (2.13.0) Active users: ... 17 Elasticsearch version 5.1 - 5.3? ... skipped (elasticsearch is disabled)
Checking GitLab ... Finished
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)