Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo <beschi.jacopo@gmail.com>2018-04-19 09:59:37 +0300
committerJacopo <beschi.jacopo@gmail.com>2018-04-19 14:56:37 +0300
commit6ae3098eb8f01406190942e8952866dd9af81dde (patch)
tree478fd89327d9248b1daadea5f3c80e29fb6180e3 /app/models/issue.rb
parent4f2e494772eb5f31929ecfdb439dfa4baa56521c (diff)
Uses Uniquify to calculate Issue#suggested_branch_name
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index c34c35bcd34..51028a404c2 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -197,10 +197,10 @@ class Issue < ActiveRecord::Base
def suggested_branch_name
return to_branch_name unless project.repository.branch_exists?(to_branch_name)
- index = 2
- index += 1 while project.repository.branch_exists?("#{to_branch_name}-#{index}")
-
- "#{to_branch_name}-#{index}"
+ start_counting_from = 2
+ Uniquify.new.string(-> (counter) { "#{to_branch_name}-#{counter}" }, start_counting_from) do |suggested_branch_name|
+ project.repository.branch_exists?(suggested_branch_name)
+ end
end
# Returns boolean if a related branch exists for the current issue