summaryrefslogtreecommitdiff
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <mail@zjvandeweg.nl>2016-02-17 07:11:48 +0100
committerZeger-Jan van de Weg <zegerjan@gitlab.com>2016-03-15 20:21:11 +0100
commitad97bebfed2e65951c7dc39ee80b32089a032804 (patch)
tree772303e5eb9d82f1d6789a8a77f0537b8ef68df8 /app/models/issue.rb
parent228007dfbcd8f97c66c1802f3b69abd7d02c7d26 (diff)
downloadgitlab-ce-ad97bebfed2e65951c7dc39ee80b32089a032804.tar.gz
Enhance new branch button on an issue
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 243d9a5db62..3b6bff6c577 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -95,7 +95,7 @@ class Issue < ActiveRecord::Base
end
def related_branches
- self.project.repository.branch_names.select { |branch| /\A#{iid}-/ =~ branch }
+ self.project.repository.branch_names.select { |branch| branch.start_with? "#{iid}-" }
end
# Reset issue events cache
@@ -126,12 +126,13 @@ class Issue < ActiveRecord::Base
end
def to_branch_name
- "#{iid}-#{title.parameterize}"[0,25]
+ "#{iid}-#{title.parameterize}"
end
- def new_branch_button?(current_user)
+ def can_be_worked_on?(current_user)
!self.closed? &&
- referenced_merge_requests(current_user).empty? &&
- related_branches.empty?
+ !self.project.forked? &&
+ referenced_merge_requests(current_user).none? { |mr| mr.closes_issue?(self) } &&
+ related_branches.empty?
end
end