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
e2d33de2
Commit
e2d33de2
authored
Jan 27, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Do not mangle dots in path of project
when specifying only name during project creation
parent
cd4cd5c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
7 deletions
+60
-7
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+12
-6
changelogs/unreleased/18292-project-name-to-path-conversion-in-api-mangles-dots.yml
...2-project-name-to-path-conversion-in-api-mangles-dots.yml
+5
-0
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+43
-1
No files found.
app/services/projects/create_service.rb
View file @
e2d33de2
...
...
@@ -210,16 +210,22 @@ module Projects
end
def
set_project_name_from_path
#
Set project name from path
if
@project
.
name
.
present?
&&
@project
.
path
.
present?
# if both name and path set - everything is ok
els
if
@project
.
path
.
present?
#
if both name and path set - everything is ok
return
if
@project
.
name
.
present?
&&
@project
.
path
.
present?
if
@project
.
path
.
present?
# Set project name from path
@project
.
name
=
@project
.
path
.
dup
elsif
@project
.
name
.
present?
# For compatibility - set path from name
# TODO: remove this in 8.0
@project
.
path
=
@project
.
name
.
dup
.
parameterize
@project
.
path
=
@project
.
name
.
dup
# TODO: Retained for backwards compatibility. Remove in API v5.
# When removed, validation errors will get bubbled up automatically.
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52725
unless
@project
.
path
.
match?
(
Gitlab
::
PathRegex
.
project_path_format_regex
)
@project
.
path
=
@project
.
path
.
parameterize
end
end
end
...
...
changelogs/unreleased/18292-project-name-to-path-conversion-in-api-mangles-dots.yml
0 → 100644
View file @
e2d33de2
---
title
:
"
API:
do
not
mangle
dots
when
creating
project
with
a
name"
merge_request
:
52725
author
:
type
:
fixed
spec/services/projects/create_service_spec.rb
View file @
e2d33de2
...
...
@@ -40,6 +40,48 @@ RSpec.describe Projects::CreateService, '#execute' do
end
end
describe
'setting name and path'
do
subject
(
:project
)
{
create_project
(
user
,
opts
)
}
context
'when both are set'
do
let
(
:opts
)
{
{
name:
'one'
,
path:
'two'
}
}
it
'keeps them as specified'
do
expect
(
project
.
name
).
to
eq
(
'one'
)
expect
(
project
.
path
).
to
eq
(
'two'
)
end
end
context
'when path is set'
do
let
(
:opts
)
{
{
name:
'one.two_three-four'
}
}
it
'sets name == path'
do
expect
(
project
.
name
).
to
eq
(
'one.two_three-four'
)
expect
(
project
.
path
).
to
eq
(
project
.
name
)
end
end
context
'when name is a valid path'
do
let
(
:opts
)
{
{
name:
'one.two_three-four'
}
}
it
'sets path == name'
do
expect
(
project
.
name
).
to
eq
(
'one.two_three-four'
)
expect
(
project
.
path
).
to
eq
(
project
.
name
)
end
end
context
'when name is not a valid path'
do
let
(
:opts
)
{
{
name:
'one.two_three-four and five'
}
}
# TODO: Retained for backwards compatibility. Remove in API v5.
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52725
it
'parameterizes the name'
do
expect
(
project
.
name
).
to
eq
(
'one.two_three-four and five'
)
expect
(
project
.
path
).
to
eq
(
'one-two_three-four-and-five'
)
end
end
end
context
'user namespace'
do
it
do
project
=
create_project
(
user
,
opts
)
...
...
@@ -419,7 +461,7 @@ RSpec.describe Projects::CreateService, '#execute' do
context
'when another repository already exists on disk'
do
let
(
:opts
)
do
{
name:
'
E
xisting'
,
name:
'
e
xisting'
,
namespace_id:
user
.
namespace
.
id
}
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