Commit cf677378 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Prefer repository.branch_exists?

parent 4f94053c
...@@ -5,7 +5,7 @@ module Files ...@@ -5,7 +5,7 @@ module Files
def execute def execute
@source_project = params[:source_project] || @project @source_project = params[:source_project] || @project
@source_branch = params[:source_branch] @source_branch = params[:source_branch]
@target_branch = params[:target_branch] @target_branch = params[:target_branch]
@commit_message = params[:commit_message] @commit_message = params[:commit_message]
@file_path = params[:file_path] @file_path = params[:file_path]
...@@ -59,12 +59,12 @@ module Files ...@@ -59,12 +59,12 @@ module Files
end end
unless project.empty_repo? unless project.empty_repo?
unless @source_project.repository.branch_names.include?(@source_branch) unless @source_project.repository.branch_exists?(@source_branch)
raise_error('You can only create or edit files when you are on a branch') raise_error('You can only create or edit files when you are on a branch')
end end
if different_branch? if different_branch?
if repository.branch_names.include?(@target_branch) if repository.branch_exists?(@target_branch)
raise_error('Branch with such name already exists. You need to switch to this branch in order to make changes') raise_error('Branch with such name already exists. You need to switch to this branch in order to make changes')
end end
end end
......
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