Commit 31e2071d authored by Kerri Miller's avatar Kerri Miller

Suggest default_branch_name when available

parent 7784c290
- @content_class = "limit-container-width" unless fluid_layout - @content_class = "limit-container-width" unless fluid_layout
- default_branch_name = Gitlab::CurrentSettings.default_branch_name.presence || "master"
- breadcrumb_title _("Details") - breadcrumb_title _("Details")
- page_title _("Details") - page_title _("Details")
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
git commit -m "add README" git commit -m "add README"
- if @project.can_current_user_push_to_default_branch? - if @project.can_current_user_push_to_default_branch?
%span>< %span><
git push -u origin master git push -u origin #{ default_branch_name }
%fieldset %fieldset
%h5= _('Push an existing folder') %h5= _('Push an existing folder')
...@@ -60,7 +61,7 @@ ...@@ -60,7 +61,7 @@
git commit -m "Initial commit" git commit -m "Initial commit"
- if @project.can_current_user_push_to_default_branch? - if @project.can_current_user_push_to_default_branch?
%span>< %span><
git push -u origin master git push -u origin #{ default_branch_name }
%fieldset %fieldset
%h5= _('Push an existing Git repository') %h5= _('Push an existing Git repository')
......
...@@ -18,6 +18,8 @@ RSpec.describe 'Projects > Show > User sees Git instructions' do ...@@ -18,6 +18,8 @@ RSpec.describe 'Projects > Show > User sees Git instructions' do
page.within '.empty-wrapper' do page.within '.empty-wrapper' do
expect(page).to have_content('Command line instructions') expect(page).to have_content('Command line instructions')
end end
expect(page).to have_content("git push -u origin master")
end end
end end
...@@ -59,6 +61,25 @@ RSpec.describe 'Projects > Show > User sees Git instructions' do ...@@ -59,6 +61,25 @@ RSpec.describe 'Projects > Show > User sees Git instructions' do
include_examples 'shows details of empty project with no repo' include_examples 'shows details of empty project with no repo'
end end
context ":default_branch_name is specified" do
let_it_be(:project) { create(:project, :public) }
before do
expect(Gitlab::CurrentSettings)
.to receive(:default_branch_name)
.and_return('example_branch')
sign_in(project.owner)
visit project_path(project)
end
it "recommends default_branch_name instead of master" do
click_link 'Create empty repository'
expect(page).to have_content("git push -u origin example_branch")
end
end
context 'when project is empty' do context 'when project is empty' do
let_it_be(:project) { create(:project_empty_repo, :public) } let_it_be(:project) { create(:project_empty_repo, :public) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment