diff options
author | Valery Sizov <valery@gitlab.com> | 2017-02-06 18:59:54 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-02-23 15:31:03 +0200 |
commit | 08e4d98cacb12f3d9b80b81ed1f50b9474c8b276 (patch) | |
tree | 69376ef4e4553a378c65ff33bb3776ff5d4bebd3 /app/controllers/projects/branches_controller.rb | |
parent | 319dfd68a82fe0b6893513a8f99962c3ea13965b (diff) | |
download | gitlab-ce-08e4d98cacb12f3d9b80b81ed1f50b9474c8b276.tar.gz |
Create master branch first if project is repository-less
Diffstat (limited to 'app/controllers/projects/branches_controller.rb')
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 89d84809e3a..f815fa1387e 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -1,8 +1,10 @@ class Projects::BranchesController < Projects::ApplicationController include ActionView::Helpers::SanitizeHelper include SortingHelper + include ProjectsHelper + # Authorize - before_action :require_non_empty_project + before_action :require_non_empty_project, except: :create before_action :authorize_download_code! before_action :authorize_push_code!, only: [:new, :create, :destroy, :destroy_all_merged] @@ -32,6 +34,8 @@ class Projects::BranchesController < Projects::ApplicationController branch_name = sanitize(strip_tags(params[:branch_name])) branch_name = Addressable::URI.unescape(branch_name) + is_redirect_to_autodeploy_needed = project.empty_repo? && project.deployment_services.present? + result = CreateBranchService.new(project, current_user). execute(branch_name, ref) @@ -42,8 +46,16 @@ class Projects::BranchesController < Projects::ApplicationController if result[:status] == :success @branch = result[:branch] - redirect_to namespace_project_tree_path(@project.namespace, @project, - @branch.name) + + if is_redirect_to_autodeploy_needed + redirect_to( + url_to_autodeploy_setup(project, branch_name), + notice: "Branch \"#{sanitize(branch_name)}\" was created. To set up auto deploy, \ + choose a GitLab CI Yaml template and commit your changes. #{view_context.link_to_autodeploy_doc}".html_safe) + else + redirect_to namespace_project_tree_path(@project.namespace, @project, + @branch.name) + end else @error = result[:message] render action: 'new' @@ -76,7 +88,7 @@ class Projects::BranchesController < Projects::ApplicationController ref_escaped = sanitize(strip_tags(params[:ref])) Addressable::URI.unescape(ref_escaped) else - @project.default_branch + @project.default_branch || 'master' end end end |