summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-26 14:40:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-26 14:40:33 +0000
commit42dd2634e347e42dc100596a6b2588e5f163322e (patch)
tree4c1e5ceb817a5739ffc79f5a16c475fda5ad9de9 /app/models
parent93fd80667dcfbacca2b41168da6fcb3f67c0899b (diff)
downloadgitlab-ce-42dd2634e347e42dc100596a6b2588e5f163322e.tar.gz
Add latest changes from gitlab-org/security/gitlab@15-3-stable-ee
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue.rb8
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