BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a53cc489
Commit
a53cc489
authored
Jul 25, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bvl-free-unused-names' into 'master'
Free some unused reserved top-level words. Closes #35053 See merge request !12932
parents
a62a2e24
d22fe96b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
20 deletions
+66
-20
bvl-free-unused-names.yml
changelogs/unreleased/bvl-free-unused-names.yml
+5
-0
path_regex.rb
lib/gitlab/path_regex.rb
+10
-10
path_regex_spec.rb
spec/lib/gitlab/path_regex_spec.rb
+51
-10
No files found.
changelogs/unreleased/bvl-free-unused-names.yml
0 → 100644
View file @
a53cc489
---
title
:
Free up some top level words, reject top level groups named like files in the
public folder
merge_request
:
12932
author
:
lib/gitlab/path_regex.rb
View file @
a53cc489
...
@@ -14,42 +14,42 @@ module Gitlab
...
@@ -14,42 +14,42 @@ module Gitlab
TOP_LEVEL_ROUTES
=
%w[
TOP_LEVEL_ROUTES
=
%w[
-
-
.well-known
.well-known
404.html
422.html
500.html
502.html
503.html
abuse_reports
abuse_reports
admin
admin
all
api
api
apple-touch-icon-precomposed.png
apple-touch-icon.png
assets
assets
autocomplete
autocomplete
ci
ci
dashboard
dashboard
deploy.html
explore
explore
favicon.ico
files
files
groups
groups
health_check
health_check
help
help
hooks
import
import
invites
invites
issues
jwt
jwt
koding
koding
member
merge_requests
new
notes
notification_settings
notification_settings
oauth
oauth
profile
profile
projects
projects
public
public
repository
robots.txt
robots.txt
s
s
search
search
sent_notifications
sent_notifications
s
ervices
s
lash-command-logo.png
snippets
snippets
teams
u
u
unicorn_test
unicorn_test
unsubscribes
unsubscribes
...
...
spec/lib/gitlab/path_regex_spec.rb
View file @
a53cc489
...
@@ -36,9 +36,12 @@ describe Gitlab::PathRegex, lib: true do
...
@@ -36,9 +36,12 @@ describe Gitlab::PathRegex, lib: true do
described_class
::
PROJECT_WILDCARD_ROUTES
.
include?
(
path
.
split
(
'/'
).
first
)
described_class
::
PROJECT_WILDCARD_ROUTES
.
include?
(
path
.
split
(
'/'
).
first
)
end
end
def
failure_message
(
missing_words
,
constant_name
,
migration_helper
)
def
failure_message
(
constant_name
,
migration_helper
,
missing_words:
[],
additional_words:
[]
)
missing_words
=
Array
(
missing_words
)
missing_words
=
Array
(
missing_words
)
<<-
MSG
additional_words
=
Array
(
additional_words
)
message
=
""
if
missing_words
.
any?
message
+=
<<-
MISSING
Found new routes that could cause conflicts with existing namespaced routes
Found new routes that could cause conflicts with existing namespaced routes
for groups or projects.
for groups or projects.
...
@@ -51,7 +54,18 @@ describe Gitlab::PathRegex, lib: true do
...
@@ -51,7 +54,18 @@ describe Gitlab::PathRegex, lib: true do
Make sure to make a note of the renamed records in the release blog post.
Make sure to make a note of the renamed records in the release blog post.
MSG
MISSING
end
if
additional_words
.
any?
message
+=
<<-
ADDITIONAL
Why are <
#{
additional_words
.
join
(
', '
)
}
> in `
#{
constant_name
}
`?
If they are really required, update these specs to reflect that.
ADDITIONAL
end
message
end
end
let
(
:all_routes
)
do
let
(
:all_routes
)
do
...
@@ -68,9 +82,23 @@ describe Gitlab::PathRegex, lib: true do
...
@@ -68,9 +82,23 @@ describe Gitlab::PathRegex, lib: true do
let
(
:routes_not_starting_in_wildcard
)
{
routes_without_format
.
select
{
|
p
|
p
!~
%r{^/[:*]}
}
}
let
(
:routes_not_starting_in_wildcard
)
{
routes_without_format
.
select
{
|
p
|
p
!~
%r{^/[:*]}
}
}
let
(
:top_level_words
)
do
let
(
:top_level_words
)
do
routes_not_starting_in_wildcard
.
map
do
|
route
|
words
=
routes_not_starting_in_wildcard
.
map
do
|
route
|
route
.
split
(
'/'
)[
1
]
route
.
split
(
'/'
)[
1
]
end
.
compact
.
uniq
end
.
compact
.
uniq
words
+
ee_top_level_words
+
files_in_public
end
let
(
:ee_top_level_words
)
do
[
'unsubscribes'
]
end
let
(
:files_in_public
)
do
git
=
Gitlab
.
config
.
git
.
bin_path
`cd
#{
Rails
.
root
}
&&
#{
git
}
ls-files public`
.
split
(
"
\n
"
)
.
map
{
|
entry
|
entry
.
gsub
(
'public/'
,
''
)
}
.
uniq
end
end
# All routes that start with a namespaced path, that have 1 or more
# All routes that start with a namespaced path, that have 1 or more
...
@@ -115,18 +143,29 @@ describe Gitlab::PathRegex, lib: true do
...
@@ -115,18 +143,29 @@ describe Gitlab::PathRegex, lib: true do
let
(
:paths_after_group_id
)
do
let
(
:paths_after_group_id
)
do
group_routes
.
map
do
|
route
|
group_routes
.
map
do
|
route
|
route
.
gsub
(
STARTING_WITH_GROUP
,
''
).
split
(
'/'
).
first
route
.
gsub
(
STARTING_WITH_GROUP
,
''
).
split
(
'/'
).
first
end
.
uniq
end
.
uniq
+
ee_paths_after_group_id
end
let
(
:ee_paths_after_group_id
)
do
%w(analytics
ldap
ldap_group_links
notification_setting
audit_events
pipeline_quota hooks)
end
end
describe
'TOP_LEVEL_ROUTES'
do
describe
'TOP_LEVEL_ROUTES'
do
it
'includes all the top level namespaces'
do
it
'includes all the top level namespaces'
do
failure_block
=
lambda
do
failure_block
=
lambda
do
missing_words
=
top_level_words
-
described_class
::
TOP_LEVEL_ROUTES
missing_words
=
top_level_words
-
described_class
::
TOP_LEVEL_ROUTES
failure_message
(
missing_words
,
'TOP_LEVEL_ROUTES'
,
'rename_root_paths'
)
additional_words
=
described_class
::
TOP_LEVEL_ROUTES
-
top_level_words
failure_message
(
'TOP_LEVEL_ROUTES'
,
'rename_root_paths'
,
missing_words:
missing_words
,
additional_words:
additional_words
)
end
end
expect
(
described_class
::
TOP_LEVEL_ROUTES
)
expect
(
described_class
::
TOP_LEVEL_ROUTES
)
.
to
include
(
*
top_level_words
),
failure_block
.
to
contain_exactly
(
*
top_level_words
),
failure_block
end
end
end
end
...
@@ -134,11 +173,13 @@ describe Gitlab::PathRegex, lib: true do
...
@@ -134,11 +173,13 @@ describe Gitlab::PathRegex, lib: true do
it
"don't contain a second wildcard"
do
it
"don't contain a second wildcard"
do
failure_block
=
lambda
do
failure_block
=
lambda
do
missing_words
=
paths_after_group_id
-
described_class
::
GROUP_ROUTES
missing_words
=
paths_after_group_id
-
described_class
::
GROUP_ROUTES
failure_message
(
missing_words
,
'GROUP_ROUTES'
,
'rename_child_paths'
)
additional_words
=
described_class
::
GROUP_ROUTES
-
paths_after_group_id
failure_message
(
'GROUP_ROUTES'
,
'rename_child_paths'
,
missing_words:
missing_words
,
additional_words:
additional_words
)
end
end
expect
(
described_class
::
GROUP_ROUTES
)
expect
(
described_class
::
GROUP_ROUTES
)
.
to
include
(
*
paths_after_group_id
),
failure_block
.
to
contain_exactly
(
*
paths_after_group_id
),
failure_block
end
end
end
end
...
@@ -147,7 +188,7 @@ describe Gitlab::PathRegex, lib: true do
...
@@ -147,7 +188,7 @@ describe Gitlab::PathRegex, lib: true do
aggregate_failures
do
aggregate_failures
do
all_wildcard_paths
.
each
do
|
path
|
all_wildcard_paths
.
each
do
|
path
|
expect
(
wildcards_include?
(
path
))
expect
(
wildcards_include?
(
path
))
.
to
be
(
true
),
failure_message
(
path
,
'PROJECT_WILDCARD_ROUTES'
,
'rename_wildcard_paths'
)
.
to
be
(
true
),
failure_message
(
'PROJECT_WILDCARD_ROUTES'
,
'rename_wildcard_paths'
,
missing_words:
path
)
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