diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2017-05-04 08:09:21 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-04 08:09:21 +0000 |
commit | b64a37c4ed5561d423ee607f9821b75fd0337168 (patch) | |
tree | 7b10e0e1938f871a2a228fe38adf3641ef6f5ce5 /app/controllers/projects/branches_controller.rb | |
parent | 8983ade27df200f7f9376d61de17f329d9d27a33 (diff) | |
download | gitlab-ce-b64a37c4ed5561d423ee607f9821b75fd0337168.tar.gz |
Allow to create new branch and empty WIP merge request from issue page
Diffstat (limited to 'app/controllers/projects/branches_controller.rb')
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 840405f38cb..f0f031303d8 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -46,20 +46,28 @@ 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] - - 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) + respond_to do |format| + format.html do + if result[:status] == :success + 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 + else + @error = result[:message] + render action: 'new' + end + end + + format.json do + if result[:status] == :success + render json: { name: branch_name, url: namespace_project_tree_url(@project.namespace, @project, branch_name) } + else + render json: result[:messsage], status: :unprocessable_entity + end end - else - @error = result[:message] - render action: 'new' end end |