summaryrefslogtreecommitdiff
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorJacopo <beschi.jacopo@gmail.com>2018-04-05 17:17:02 +0200
committerJacopo <beschi.jacopo@gmail.com>2018-04-19 13:56:36 +0200
commit5a29a304be5fc86a5bbe61764c47cdd8069e2103 (patch)
tree97e0e8ac539e7e03fd562f2b3dc77611c246acd1 /app/models/issue.rb
parent674702e02e2654e539e1b3c9a12d6b9897a614cf (diff)
downloadgitlab-ce-5a29a304be5fc86a5bbe61764c47cdd8069e2103.tar.gz
Shows new branch/mr button even when branch exists
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 7611e83647c..c34c35bcd34 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -194,6 +194,15 @@ class Issue < ActiveRecord::Base
branches_with_iid - branches_with_merge_request
end
+ 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}"
+ end
+
# Returns boolean if a related branch exists for the current issue
# ignores merge requests branchs
def has_related_branch?
@@ -248,11 +257,8 @@ class Issue < ActiveRecord::Base
end
end
- def can_be_worked_on?(current_user)
- !self.closed? &&
- !self.project.forked? &&
- self.related_branches(current_user).empty? &&
- self.closed_by_merge_requests(current_user).empty?
+ def can_be_worked_on?
+ !self.closed? && !self.project.forked?
end
# Returns `true` if the current issue can be viewed by either a logged in User