Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9ccec6d3
Commit
9ccec6d3
authored
Jul 02, 2020
by
Kerri Miller
Committed by
Bob Van Landuyt
Jul 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `default_branch_name` when initializing w/README.md
parent
d52619d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+1
-1
changelogs/unreleased/225592-read-default_branch_name-when-initializing-w-readme-md.yml
...ead-default_branch_name-when-initializing-w-readme-md.yml
+6
-0
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+26
-5
No files found.
app/services/projects/create_service.rb
View file @
9ccec6d3
...
...
@@ -135,7 +135,7 @@ module Projects
def
create_readme
commit_attrs
=
{
branch_name:
'master'
,
branch_name:
Gitlab
::
CurrentSettings
.
default_branch_name
.
presence
||
'master'
,
commit_message:
'Initial commit'
,
file_path:
'README.md'
,
file_content:
"#
#{
@project
.
name
}
\n\n
#{
@project
.
description
}
"
...
...
changelogs/unreleased/225592-read-default_branch_name-when-initializing-w-readme-md.yml
0 → 100644
View file @
9ccec6d3
---
title
:
Use the application's default_branch_name when available when initializing a new repo with
a README
merge_request
:
35801
author
:
type
:
changed
spec/services/projects/create_service_spec.rb
View file @
9ccec6d3
...
...
@@ -446,14 +446,35 @@ RSpec.describe Projects::CreateService, '#execute' do
end
context
'when readme initialization is requested'
do
it
'creates README.md'
do
let
(
:project
)
{
create_project
(
user
,
opts
)
}
before
do
opts
[
:initialize_with_readme
]
=
'1'
end
project
=
create_project
(
user
,
opts
)
shared_examples
'creates README.md'
do
it
{
expect
(
project
.
repository
.
commit_count
).
to
be
(
1
)
}
it
{
expect
(
project
.
repository
.
readme
.
name
).
to
eql
(
'README.md'
)
}
it
{
expect
(
project
.
repository
.
readme
.
data
).
to
include
(
'# GitLab'
)
}
end
it_behaves_like
'creates README.md'
expect
(
project
.
repository
.
commit_count
).
to
be
(
1
)
expect
(
project
.
repository
.
readme
.
name
).
to
eql
(
'README.md'
)
expect
(
project
.
repository
.
readme
.
data
).
to
include
(
'# GitLab'
)
context
'and a default_branch_name is specified'
do
before
do
allow
(
Gitlab
::
CurrentSettings
)
.
to
receive
(
:default_branch_name
)
.
and_return
(
'example_branch'
)
end
it_behaves_like
'creates README.md'
it
'creates README.md within the specified branch rather than master'
do
branches
=
project
.
repository
.
branches
expect
(
branches
.
size
).
to
eq
(
1
)
expect
(
branches
.
collect
(
&
:name
)).
to
contain_exactly
(
'example_branch'
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment