diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-26 17:40:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-26 17:40:33 +0300 |
commit | 42dd2634e347e42dc100596a6b2588e5f163322e (patch) | |
tree | 4c1e5ceb817a5739ffc79f5a16c475fda5ad9de9 /app | |
parent | 93fd80667dcfbacca2b41168da6fcb3f67c0899b (diff) |
Add latest changes from gitlab-org/security/gitlab@15-3-stable-ee
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 4114467eb25..df8ee34b3c3 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -458,7 +458,13 @@ class Issue < ApplicationRecord return to_branch_name unless project.repository.branch_exists?(to_branch_name) start_counting_from = 2 - Uniquify.new(start_counting_from).string(-> (counter) { "#{to_branch_name}-#{counter}" }) do |suggested_branch_name| + + branch_name_generator = -> (counter) do + suffix = counter > 5 ? SecureRandom.hex(8) : counter + "#{to_branch_name}-#{suffix}" + end + + Uniquify.new(start_counting_from).string(branch_name_generator) do |suggested_branch_name| project.repository.branch_exists?(suggested_branch_name) end end |