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
54baf3a3
Commit
54baf3a3
authored
Mar 26, 2018
by
Jan
Committed by
Douwe Maan
Mar 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Forking with namespace doesn't work (API)"
parent
bf272756
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
10 deletions
+22
-10
changelogs/unreleased/fix-40798-namespace-forking.yml
changelogs/unreleased/fix-40798-namespace-forking.yml
+5
-0
lib/api/projects.rb
lib/api/projects.rb
+1
-5
lib/api/v3/projects.rb
lib/api/v3/projects.rb
+1
-5
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+15
-0
No files found.
changelogs/unreleased/fix-40798-namespace-forking.yml
0 → 100644
View file @
54baf3a3
---
title
:
Fix forking to subgroup via API when namespace is given by name
merge_request
:
17815
author
:
Jan Beckmann
type
:
fixed
lib/api/projects.rb
View file @
54baf3a3
...
...
@@ -228,11 +228,7 @@ module API
namespace_id
=
fork_params
[
:namespace
]
if
namespace_id
.
present?
fork_params
[
:namespace
]
=
if
namespace_id
=~
/^\d+$/
Namespace
.
find_by
(
id:
namespace_id
)
else
Namespace
.
find_by_path_or_name
(
namespace_id
)
end
fork_params
[
:namespace
]
=
find_namespace
(
namespace_id
)
unless
fork_params
[
:namespace
]
&&
can?
(
current_user
,
:create_projects
,
fork_params
[
:namespace
])
not_found!
(
'Target Namespace'
)
...
...
lib/api/v3/projects.rb
View file @
54baf3a3
...
...
@@ -268,11 +268,7 @@ module API
namespace_id
=
fork_params
[
:namespace
]
if
namespace_id
.
present?
fork_params
[
:namespace
]
=
if
namespace_id
=~
/^\d+$/
Namespace
.
find_by
(
id:
namespace_id
)
else
Namespace
.
find_by_path_or_name
(
namespace_id
)
end
fork_params
[
:namespace
]
=
find_namespace
(
namespace_id
)
unless
fork_params
[
:namespace
]
&&
can?
(
current_user
,
:create_projects
,
fork_params
[
:namespace
])
not_found!
(
'Target Namespace'
)
...
...
spec/requests/api/projects_spec.rb
View file @
54baf3a3
...
...
@@ -1718,6 +1718,12 @@ describe API::Projects do
group
end
let
(
:group3
)
do
group
=
create
(
:group
,
name:
'group3_name'
,
parent:
group2
)
group
.
add_owner
(
user2
)
group
end
before
do
project
.
add_reporter
(
user2
)
end
...
...
@@ -1813,6 +1819,15 @@ describe API::Projects do
expect
(
json_response
[
'namespace'
][
'name'
]).
to
eq
(
group2
.
name
)
end
it
'forks to owned subgroup'
do
full_path
=
"
#{
group2
.
path
}
/
#{
group3
.
path
}
"
post
api
(
"/projects/
#{
project
.
id
}
/fork"
,
user2
),
namespace:
full_path
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
json_response
[
'namespace'
][
'name'
]).
to
eq
(
group3
.
name
)
expect
(
json_response
[
'namespace'
][
'full_path'
]).
to
eq
(
full_path
)
end
it
'fails to fork to not owned group'
do
post
api
(
"/projects/
#{
project
.
id
}
/fork"
,
user2
),
namespace:
group
.
name
...
...
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