Use existing methods for branch names: Ex use @repository.branch_names instead of @repository.heads.map(&:name)

This commit is contained in:
Dmitriy Zaporozhets 2013-03-31 17:08:10 +03:00
parent 025e41576e
commit 71b0f8ea0b
5 changed files with 32 additions and 13 deletions

View file

@ -129,11 +129,11 @@ class MergeRequestsController < ProjectResourceController
def validates_merge_request
# Show git not found page if target branch doesn't exist
return invalid_mr unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch)
return invalid_mr unless @project.repository.branch_names.include?(@merge_request.target_branch)
# Show git not found page if source branch doesn't exist
# and there is no saved commits between source & target branch
return invalid_mr if !@project.repo.heads.map(&:name).include?(@merge_request.source_branch) && @merge_request.commits.blank?
return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch) && @merge_request.commits.blank?
end
def define_show_vars