Wildcard branch protection via REST api
Description
Wildcard branch protection is supported in the Gitlab UI. It is not possible to protect branches with wildcard via REST api call.
We'd like to protect some common branch name patterns in our projects, e.g. stable/*
. We could do this manually, but on new project creation it is likely that this is forgotte, so we would like to use a web hook to trigger an api call for this.
Proposal
It should be possible to protect branches by api call like
PUT /api/v3/projects/58/repository/branches/stable-*/protect?developers_can_push=true
At the moment, this call results in a HTTP 500 internal server error and the gitlab-rails/production.log shows
Started PUT "/api/v3/projects/58/repository/branches/stable-*/protect?developers_can_push=true" for 10.10.62.41 at 2016-11-09 10:35:25 +0100
Rugged::ReferenceError (Cannot locate local branch 'stable-*'):
/opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/gitlab_git-10.6.8/lib/gitlab_git/repository.rb:85:in `[]'
/opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/gitlab_git-10.6.8/lib/gitlab_git/repository.rb:85:in `find_branch'
/opt/gitlab/embedded/service/gitlab-rails/app/models/repository.rb:139:in `find_branch'
Links / references
https://forum.gitlab.com/t/wildcard-branch-protection-via-rest-api/5003