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
30fec06b
Commit
30fec06b
authored
Dec 24, 2019
by
Dmitriy Zaporozhets
Committed by
Sean McGivern
Dec 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy repository route under - scope
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
99544822
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
27 deletions
+56
-27
changelogs/unreleased/dz-move-repo-routes-2.yml
changelogs/unreleased/dz-move-repo-routes-2.yml
+5
-0
config/routes/project.rb
config/routes/project.rb
+9
-1
config/routes/repository.rb
config/routes/repository.rb
+0
-26
config/routes/repository_scoped.rb
config/routes/repository_scoped.rb
+34
-0
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+8
-0
No files found.
changelogs/unreleased/dz-move-repo-routes-2.yml
0 → 100644
View file @
30fec06b
---
title
:
Copy repository route under - scope
merge_request
:
22092
author
:
type
:
changed
config/routes/project.rb
View file @
30fec06b
...
...
@@ -274,8 +274,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
# The wiki routing contains wildcard characters so
# The wiki
and repository
routing contains wildcard characters so
# its preferable to keep it below all other project routes
draw
:repository_scoped
draw
:wiki
end
# End of the /-/ scope.
...
...
@@ -481,6 +482,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# its preferable to keep it below all other project routes
draw
:repository
# To ensure an old unscoped routing is used for the UI we need to
# add prefix 'as' to the scope routing and place it below original routing.
# Issue https://gitlab.com/gitlab-org/gitlab/issues/118849
scope
'-'
,
as:
'scoped'
do
draw
:repository
end
# All new routes should go under /-/ scope.
# Look for scope '-' at the top of the file.
# rubocop: enable Cop/PutProjectRoutesUnderScope
...
...
config/routes/repository.rb
View file @
30fec06b
...
...
@@ -39,32 +39,6 @@ scope format: false do
end
end
scope
path:
'-'
,
constraints:
{
id:
Gitlab
::
PathRegex
.
git_reference_regex
}
do
resources
:network
,
only:
[
:show
]
resources
:graphs
,
only:
[
:show
]
do
member
do
get
:charts
get
:commits
get
:ci
get
:languages
end
end
get
'/branches/:state'
,
to:
'branches#index'
,
as: :branches_filtered
,
constraints:
{
state:
/active|stale|all/
}
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
]
do
get
:diverging_commit_counts
,
on: :collection
end
delete
:merged_branches
,
controller:
'branches'
,
action: :destroy_all_merged
resources
:tags
,
only:
[
:index
,
:show
,
:new
,
:create
,
:destroy
]
do
resource
:release
,
controller:
'tags/releases'
,
only:
[
:edit
,
:update
]
end
resources
:protected_branches
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
,
:patch
],
constraints:
{
id:
Gitlab
::
PathRegex
.
git_reference_regex
}
resources
:protected_tags
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
]
end
scope
constraints:
{
id:
/[^\0]+/
}
do
scope
controller: :blob
do
get
'/new/*id'
,
action: :new
,
as: :new_blob
...
...
config/routes/repository_scoped.rb
0 → 100644
View file @
30fec06b
# frozen_string_literal: true
# All routing related to repository browsing
# that is already under /-/ scope only
# Don't use format parameter as file extension (old 3.0.x behavior)
# See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
scope
format:
false
do
scope
constraints:
{
id:
Gitlab
::
PathRegex
.
git_reference_regex
}
do
resources
:network
,
only:
[
:show
]
resources
:graphs
,
only:
[
:show
]
do
member
do
get
:charts
get
:commits
get
:ci
get
:languages
end
end
get
'/branches/:state'
,
to:
'branches#index'
,
as: :branches_filtered
,
constraints:
{
state:
/active|stale|all/
}
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
]
do
get
:diverging_commit_counts
,
on: :collection
end
delete
:merged_branches
,
controller:
'branches'
,
action: :destroy_all_merged
resources
:tags
,
only:
[
:index
,
:show
,
:new
,
:create
,
:destroy
]
do
resource
:release
,
controller:
'tags/releases'
,
only:
[
:edit
,
:update
]
end
resources
:protected_branches
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
,
:patch
],
constraints:
{
id:
Gitlab
::
PathRegex
.
git_reference_regex
}
resources
:protected_tags
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
]
end
end
spec/routing/project_routing_spec.rb
View file @
30fec06b
...
...
@@ -579,6 +579,10 @@ describe 'project routing' do
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
"blob/master/blob/
#{
newline_file
}
"
})
end
it
'to #show from scope routing'
do
expect
(
get
(
'/gitlab/gitlabhq/-/blob/master/app/models/project.rb'
)).
to
route_to
(
'projects/blob#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'master/app/models/project.rb'
)
end
end
# project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /[^\0]+/, project_id: /[^\/]+/}
...
...
@@ -596,6 +600,10 @@ describe 'project routing' do
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
"master/
#{
newline_file
}
"
})
end
it
'to #show from scope routing'
do
expect
(
get
(
'/gitlab/gitlabhq/-/tree/master/app/models/project.rb'
)).
to
route_to
(
'projects/tree#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'master/app/models/project.rb'
)
end
end
# project_find_file GET /:namespace_id/:project_id/find_file/*id(.:format) projects/find_file#show {:id=>/[^\0]+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/html/}
...
...
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