diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-27 22:05:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-27 22:06:03 +0300 |
commit | bbcd372db175c8f19b4b72453ff57c9a19887c5f (patch) | |
tree | 6b9f1cdaf9387b79a1a500e45a5c1aef9feba2d4 /app | |
parent | d625f4e9fe78a69be0d481c20cba33b6dd88ef1a (diff) |
Add latest changes from gitlab-org/security/gitlab@15-2-stable-ee
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 1 | ||||
-rw-r--r-- | app/models/repository.rb | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 46e25564eab..ebfec34c3e1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2119,6 +2119,7 @@ class Project < ApplicationRecord end def after_import + repository.remove_prohibited_branches repository.expire_content_cache wiki.repository.expire_content_cache diff --git a/app/models/repository.rb b/app/models/repository.rb index 0da71d87457..9039bdf1a20 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1168,6 +1168,16 @@ class Repository @cache ||= Gitlab::RepositoryCache.new(self) end + def remove_prohibited_branches + return unless exists? + + prohibited_branches = raw_repository.branch_names.select { |name| name.match(/\A\h{40}\z/) } + + return if prohibited_branches.blank? + + prohibited_branches.each { |name| raw_repository.delete_branch(name) } + end + private # TODO Genericize finder, later split this on finders by Ref or Oid |