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
6765e044
Commit
6765e044
authored
Oct 15, 2020
by
Kerri Miller
Committed by
Markus Koller
Oct 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respect Group's default branch name when present
parent
d6954c00
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
10 deletions
+63
-10
app/models/concerns/has_repository.rb
app/models/concerns/has_repository.rb
+5
-1
app/models/group.rb
app/models/group.rb
+4
-0
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+1
-1
app/views/projects/empty.html.haml
app/views/projects/empty.html.haml
+1
-1
changelogs/unreleased/251963-respect-group-s-default-branch-name-when-present.yml
...1963-respect-group-s-default-branch-name-when-present.yml
+5
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+22
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+25
-7
No files found.
app/models/concerns/has_repository.rb
View file @
6765e044
...
@@ -84,7 +84,11 @@ module HasRepository
...
@@ -84,7 +84,11 @@ module HasRepository
end
end
def
default_branch_from_preferences
def
default_branch_from_preferences
empty_repo?
?
Gitlab
::
CurrentSettings
.
default_branch_name
:
nil
return
unless
empty_repo?
group_branch_default_name
=
group
&
.
default_branch_name
if
respond_to?
(
:group
)
group_branch_default_name
||
Gitlab
::
CurrentSettings
.
default_branch_name
end
end
def
reload_default_branch
def
reload_default_branch
...
...
app/models/group.rb
View file @
6765e044
...
@@ -552,6 +552,10 @@ class Group < Namespace
...
@@ -552,6 +552,10 @@ class Group < Namespace
owners
.
first
||
parent
&
.
default_owner
||
owner
owners
.
first
||
parent
&
.
default_owner
||
owner
end
end
def
default_branch_name
namespace_settings
&
.
default_branch_name
end
def
access_level_roles
def
access_level_roles
GroupMember
.
access_level_roles
GroupMember
.
access_level_roles
end
end
...
...
app/services/projects/create_service.rb
View file @
6765e044
...
@@ -147,7 +147,7 @@ module Projects
...
@@ -147,7 +147,7 @@ module Projects
def
create_readme
def
create_readme
commit_attrs
=
{
commit_attrs
=
{
branch_name:
Gitlab
::
CurrentSettings
.
default_branch_name
.
presence
||
'master'
,
branch_name:
@project
.
default_branch
||
'master'
,
commit_message:
'Initial commit'
,
commit_message:
'Initial commit'
,
file_path:
'README.md'
,
file_path:
'README.md'
,
file_content:
"#
#{
@project
.
name
}
\n\n
#{
@project
.
description
}
"
file_content:
"#
#{
@project
.
name
}
\n\n
#{
@project
.
description
}
"
...
...
app/views/projects/empty.html.haml
View file @
6765e044
-
@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"
-
default_branch_name
=
@project
.
default_branch
||
"master"
-
breadcrumb_title
_
(
"Details"
)
-
breadcrumb_title
_
(
"Details"
)
-
page_title
_
(
"Details"
)
-
page_title
_
(
"Details"
)
...
...
changelogs/unreleased/251963-respect-group-s-default-branch-name-when-present.yml
0 → 100644
View file @
6765e044
---
title
:
Respect Group's default branch name when present
merge_request
:
44370
author
:
type
:
changed
spec/models/group_spec.rb
View file @
6765e044
...
@@ -1506,6 +1506,28 @@ RSpec.describe Group do
...
@@ -1506,6 +1506,28 @@ RSpec.describe Group do
end
end
end
end
describe
"#default_branch_name"
do
context
"group.namespace_settings does not have a default branch name"
do
it
"returns nil"
do
expect
(
group
.
default_branch_name
).
to
be_nil
end
end
context
"group.namespace_settings has a default branch name"
do
let
(
:example_branch_name
)
{
"example_branch_name"
}
before
do
expect
(
group
.
namespace_settings
)
.
to
receive
(
:default_branch_name
)
.
and_return
(
example_branch_name
)
end
it
"returns the default branch name"
do
expect
(
group
.
default_branch_name
).
to
eq
(
example_branch_name
)
end
end
end
describe
'#default_owner'
do
describe
'#default_owner'
do
let
(
:group
)
{
build
(
:group
)
}
let
(
:group
)
{
build
(
:group
)
}
...
...
spec/models/project_spec.rb
View file @
6765e044
...
@@ -4979,15 +4979,21 @@ RSpec.describe Project do
...
@@ -4979,15 +4979,21 @@ RSpec.describe Project do
context
"with an empty repository"
do
context
"with an empty repository"
do
let_it_be
(
:project
)
{
create
(
:project_empty_repo
)
}
let_it_be
(
:project
)
{
create
(
:project_empty_repo
)
}
context
"Gitlab::CurrentSettings.default_branch_name is unavailable"
do
context
"group.default_branch_name is available"
do
let
(
:project_group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
path:
'avatar'
,
namespace:
project_group
)
}
before
do
before
do
expect
(
Gitlab
::
CurrentSettings
)
expect
(
Gitlab
::
CurrentSettings
)
.
not_to
receive
(
:default_branch_name
)
expect
(
project
.
group
)
.
to
receive
(
:default_branch_name
)
.
to
receive
(
:default_branch_name
)
.
and_return
(
nil
)
.
and_return
(
'example_branch'
)
end
end
it
"returns th
a
t value"
do
it
"returns th
e group defaul
t value"
do
expect
(
project
.
default_branch
).
to
be_nil
expect
(
project
.
default_branch
).
to
eq
(
"example_branch"
)
end
end
end
end
...
@@ -4995,11 +5001,23 @@ RSpec.describe Project do
...
@@ -4995,11 +5001,23 @@ RSpec.describe Project do
before
do
before
do
expect
(
Gitlab
::
CurrentSettings
)
expect
(
Gitlab
::
CurrentSettings
)
.
to
receive
(
:default_branch_name
)
.
to
receive
(
:default_branch_name
)
.
and_return
(
'example_branch'
)
.
and_return
(
example_branch_name
)
end
end
it
"returns that value"
do
context
"is missing or nil"
do
expect
(
project
.
default_branch
).
to
eq
(
"example_branch"
)
let
(
:example_branch_name
)
{
nil
}
it
"returns nil"
do
expect
(
project
.
default_branch
).
to
be_nil
end
end
context
"is present"
do
let
(
:example_branch_name
)
{
"example_branch_name"
}
it
"returns the expected branch name"
do
expect
(
project
.
default_branch
).
to
eq
(
example_branch_name
)
end
end
end
end
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