Move project default branch settings under 'Repository'

- Updates specs accordingly
- Updates docs accordingly
- Brews a fresh pot
This commit is contained in:
Paul Slaughter 2018-08-25 17:32:59 +02:00
parent afb49b044b
commit b47015ad9b
7 changed files with 60 additions and 14 deletions

View file

@ -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"

View file

@ -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

View file

@ -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.

View file

@ -0,0 +1,5 @@
---
title: Move project settings for default branch under "Repository"
merge_request: 21380
author:
type: changed

View file

@ -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),

View file

@ -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 ""

View file

@ -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'
end
context 'with normal project' do
let(:project) { create(:project, :repository, namespace: user.namespace) }
expect(find(:css, 'select#project_default_branch').value).to eq 'fix'
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
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