summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/projects/default_branch/_show.html.haml21
-rw-r--r--app/views/projects/edit.html.haml5
-rw-r--r--app/views/projects/settings/repository/show.html.haml1
-rw-r--r--changelogs/unreleased/36048-move-default-branch-settings-under-repository.yml5
-rw-r--r--doc/user/project/repository/branches/index.md2
-rw-r--r--locale/gitlab.pot9
-rw-r--r--spec/features/projects/settings/user_changes_default_branch_spec.rb29
7 files changed, 59 insertions, 13 deletions
diff --git a/app/views/projects/default_branch/_show.html.haml b/app/views/projects/default_branch/_show.html.haml
new file mode 100644
index 00000000000..ff6a9d49a61
--- /dev/null
+++ b/app/views/projects/default_branch/_show.html.haml
@@ -0,0 +1,21 @@
+- expanded = Rails.env.test?
+
+%section.settings.no-animate#default-branch-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4= _('Default Branch')
+ %button.btn.js-settings-toggle
+ = expanded ? _('Collapse') : _('Expand')
+ %p
+ = _('Select the branch you want to set as the default for this project. All merge requests and commits will automatically be made against this branch unless you specify a different one.')
+
+ .settings-content
+ - if @project.empty_repo?
+ .text-secondary
+ = _('A default branch cannot be chosen for an empty project.')
+ - else
+ = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, anchor: 'default-branch-settings' }, authenticity_token: true do |f|
+ %fieldset
+ .form-group
+ = f.label :default_branch, "Default Branch", class: 'label-bold'
+ = f.select(:default_branch, @project.repository.branch_names, {}, {class: 'select2 select-wide'})
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index fb837b27207..acdde9e0f70 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -36,11 +36,6 @@
= render_if_exists 'projects/classification_policy_settings', f: f
- - unless @project.empty_repo?
- .form-group
- = f.label :default_branch, "Default Branch", class: 'label-bold'
- = f.select(:default_branch, @project.repository.branch_names, {}, {class: 'select2 select-wide'})
-
= render_if_exists 'shared/repository_size_limit_setting', form: f, type: :project
.form-group
diff --git a/app/views/projects/settings/repository/show.html.haml b/app/views/projects/settings/repository/show.html.haml
index 98c609d7bd4..a0bcaaf3c54 100644
--- a/app/views/projects/settings/repository/show.html.haml
+++ b/app/views/projects/settings/repository/show.html.haml
@@ -2,6 +2,7 @@
- page_title _("Repository")
- @content_class = "limit-container-width" unless fluid_layout
+= render "projects/default_branch/show"
= render "projects/mirrors/show"
-# Protected branches & tags use a lot of nested partials.
diff --git a/changelogs/unreleased/36048-move-default-branch-settings-under-repository.yml b/changelogs/unreleased/36048-move-default-branch-settings-under-repository.yml
new file mode 100644
index 00000000000..c5788a40dba
--- /dev/null
+++ b/changelogs/unreleased/36048-move-default-branch-settings-under-repository.yml
@@ -0,0 +1,5 @@
+---
+title: Move project settings for default branch under "Repository"
+merge_request: 21380
+author:
+type: changed
diff --git a/doc/user/project/repository/branches/index.md b/doc/user/project/repository/branches/index.md
index 9d16a4c74f2..19417d91fec 100644
--- a/doc/user/project/repository/branches/index.md
+++ b/doc/user/project/repository/branches/index.md
@@ -16,7 +16,7 @@ See also:
When you create a new [project](../../index.md), GitLab sets `master` as the default
branch for your project. You can choose another branch to be your project's
-default under your project's **Settings > General**.
+default under your project's **Settings > Repository**.
The default branch is the branch affected by the
[issue closing pattern](../../issues/automatic_issue_closing.md),
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 5f9b02bd559..7d0bd01142c 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -250,6 +250,9 @@ msgstr ""
msgid "A collection of graphs regarding Continuous Integration"
msgstr ""
+msgid "A default branch cannot be chosen for an empty project."
+msgstr ""
+
msgid "A new branch will be created in your fork and a new merge request will be started."
msgstr ""
@@ -2086,6 +2089,9 @@ msgstr ""
msgid "Decline and sign out"
msgstr ""
+msgid "Default Branch"
+msgstr ""
+
msgid "Default: Directly import the Google Code email address or username"
msgstr ""
@@ -5062,6 +5068,9 @@ msgstr ""
msgid "Select target branch"
msgstr ""
+msgid "Select the branch you want to set as the default for this project. All merge requests and commits will automatically be made against this branch unless you specify a different one."
+msgstr ""
+
msgid "Selecting a GitLab user will add a link to the GitLab user in the descriptions of issues and comments (e.g. \"By <a href=\"#\">@johnsmith</a>\"). It will also associate and/or assign these issues and comments with the selected user."
msgstr ""
diff --git a/spec/features/projects/settings/user_changes_default_branch_spec.rb b/spec/features/projects/settings/user_changes_default_branch_spec.rb
index e925539351d..fcf05e04a5c 100644
--- a/spec/features/projects/settings/user_changes_default_branch_spec.rb
+++ b/spec/features/projects/settings/user_changes_default_branch_spec.rb
@@ -1,20 +1,35 @@
require 'spec_helper'
describe 'Projects > Settings > User changes default branch' do
+ include Select2Helper
+
let(:user) { create(:user) }
- let(:project) { create(:project, :repository, namespace: user.namespace) }
before do
sign_in(user)
- visit edit_project_path(project)
+
+ visit project_settings_repository_path(project)
end
- it 'allows to change the default branch' do
- select 'fix', from: 'project_default_branch'
- page.within '.general-settings' do
- click_button 'Save changes'
+ context 'with normal project' do
+ let(:project) { create(:project, :repository, namespace: user.namespace) }
+
+ it 'allows to change the default branch', :js do
+ select2('fix', from: '#project_default_branch')
+
+ page.within '#default-branch-settings' do
+ click_button 'Save changes'
+ end
+
+ expect(find('#project_default_branch', visible: false).value).to eq 'fix'
end
+ end
- expect(find(:css, 'select#project_default_branch').value).to eq 'fix'
+ context 'with empty project' do
+ let(:project) { create(:project_empty_repo, namespace: user.namespace) }
+
+ it 'does not show default branch selector' do
+ expect(page).not_to have_selector('#project_default_branch')
+ end
end
end