Commit 944a8fa4 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use branch_exists? to check branches

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7237#note_19747922
parent d03c605b
...@@ -150,14 +150,14 @@ class GitOperationService ...@@ -150,14 +150,14 @@ class GitOperationService
' :source_project is different from current project' ' :source_project is different from current project'
end end
unless source_project.repository.commit(source_branch_name).try(:sha) unless source_project.repository.branch_exists?(source_branch_name)
raise Repository::CommitError.new( raise Repository::CommitError.new(
"Cannot find branch #{branch_name} nor" \ "Cannot find branch #{branch_name} nor" \
" #{source_branch_name} from" \ " #{source_branch_name} from" \
" #{source_project.path_with_namespace}") " #{source_project.path_with_namespace}")
end end
elsif source_branch_name elsif source_branch_name
unless repository.commit(source_branch_name).try(:sha) unless repository.branch_exists?(source_branch_name)
raise Repository::CommitError.new( raise Repository::CommitError.new(
"Cannot find branch #{branch_name} nor" \ "Cannot find branch #{branch_name} nor" \
" #{source_branch_name} from" \ " #{source_branch_name} from" \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment