summaryrefslogtreecommitdiff
path: root/app/controllers/projects/branches_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/branches_controller.rb')
-rw-r--r--app/controllers/projects/branches_controller.rb32
1 files changed, 21 insertions, 11 deletions
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb
index 840405f38cb..71374925235 100644
--- a/app/controllers/projects/branches_controller.rb
+++ b/app/controllers/projects/branches_controller.rb
@@ -46,20 +46,30 @@ class Projects::BranchesController < Projects::ApplicationController
SystemNoteService.new_issue_branch(issue, @project, current_user, branch_name) if issue
end
- if result[:status] == :success
- @branch = result[:branch]
+ respond_to do |format|
+ if result[:status] == :success
+ @branch = result[:branch]
+
+ format.html do
+ if redirect_to_autodeploy
+ redirect_to url_to_autodeploy_setup(project, branch_name),
+ notice: view_context.autodeploy_flash_notice(branch_name)
+ else
+ redirect_to namespace_project_tree_path(@project.namespace, @project, @branch.name)
+ end
+ end
- if redirect_to_autodeploy
- redirect_to(
- url_to_autodeploy_setup(project, branch_name),
- notice: view_context.autodeploy_flash_notice(branch_name))
+ format.json do
+ render json: { name: @branch.name, url: namespace_project_tree_url(@project.namespace, @project, @branch.name) }
+ end
else
- redirect_to namespace_project_tree_path(@project.namespace, @project,
- @branch.name)
+ format.html do
+ @error = result[:message]
+ render action: 'new'
+ end
+
+ format.json { render json: result[:messsage], status: :unprocessable_entity }
end
- else
- @error = result[:message]
- render action: 'new'
end
end