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
c0116926
Commit
c0116926
authored
Apr 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename namespace_regex to namespace_path_regex.
parent
164a29df
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
13 deletions
+13
-13
app/models/namespace.rb
app/models/namespace.rb
+2
-2
app/models/user.rb
app/models/user.rb
+2
-2
lib/gitlab/markdown/cross_project_reference.rb
lib/gitlab/markdown/cross_project_reference.rb
+1
-1
lib/gitlab/markdown/user_reference_filter.rb
lib/gitlab/markdown/user_reference_filter.rb
+1
-1
lib/gitlab/reference_extractor.rb
lib/gitlab/reference_extractor.rb
+1
-1
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+4
-4
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+2
-2
No files found.
app/models/namespace.rb
View file @
c0116926
...
@@ -33,8 +33,8 @@ class Namespace < ActiveRecord::Base
...
@@ -33,8 +33,8 @@ class Namespace < ActiveRecord::Base
presence:
true
,
presence:
true
,
length:
{
within:
1
..
255
},
length:
{
within:
1
..
255
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
namespace_regex
,
format:
{
with:
Gitlab
::
Regex
.
namespace_
path_
regex
,
message:
Gitlab
::
Regex
.
namespace_regex_message
}
message:
Gitlab
::
Regex
.
namespace_
path_
regex_message
}
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
...
...
app/models/user.rb
View file @
c0116926
...
@@ -131,8 +131,8 @@ class User < ActiveRecord::Base
...
@@ -131,8 +131,8 @@ class User < ActiveRecord::Base
presence:
true
,
presence:
true
,
uniqueness:
{
case_sensitive:
false
},
uniqueness:
{
case_sensitive:
false
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
namespace_regex
,
format:
{
with:
Gitlab
::
Regex
.
namespace_
path_
regex
,
message:
Gitlab
::
Regex
.
namespace_regex_message
}
message:
Gitlab
::
Regex
.
namespace_
path_
regex_message
}
validates
:notification_level
,
inclusion:
{
in:
Notification
.
notification_levels
},
presence:
true
validates
:notification_level
,
inclusion:
{
in:
Notification
.
notification_levels
},
presence:
true
validate
:namespace_uniq
,
if:
->
(
user
)
{
user
.
username_changed?
}
validate
:namespace_uniq
,
if:
->
(
user
)
{
user
.
username_changed?
}
...
...
lib/gitlab/markdown/cross_project_reference.rb
View file @
c0116926
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
# Common methods for ReferenceFilters that support an optional cross-project
# Common methods for ReferenceFilters that support an optional cross-project
# reference.
# reference.
module
CrossProjectReference
module
CrossProjectReference
NAMING_PATTERN
=
Gitlab
::
Regex
::
NAMESPACE_REGEX_STR
NAMING_PATTERN
=
Gitlab
::
Regex
::
NAMESPACE_
PATH_
REGEX_STR
PROJECT_PATTERN
=
"(?<project>
#{
NAMING_PATTERN
}
/
#{
NAMING_PATTERN
}
)"
PROJECT_PATTERN
=
"(?<project>
#{
NAMING_PATTERN
}
/
#{
NAMING_PATTERN
}
)"
# Given a cross-project reference string, get the Project record
# Given a cross-project reference string, get the Project record
...
...
lib/gitlab/markdown/user_reference_filter.rb
View file @
c0116926
...
@@ -22,7 +22,7 @@ module Gitlab
...
@@ -22,7 +22,7 @@ module Gitlab
end
end
# Pattern used to extract `@user` user references from text
# Pattern used to extract `@user` user references from text
USER_PATTERN
=
/@(?<user>
#{
Gitlab
::
Regex
::
NAMESPACE_REGEX_STR
}
)/
USER_PATTERN
=
/@(?<user>
#{
Gitlab
::
Regex
::
NAMESPACE_
PATH_
REGEX_STR
}
)/
def
call
def
call
replace_text_nodes_matching
(
USER_PATTERN
)
do
|
content
|
replace_text_nodes_matching
(
USER_PATTERN
)
do
|
content
|
...
...
lib/gitlab/reference_extractor.rb
View file @
c0116926
...
@@ -85,7 +85,7 @@ module Gitlab
...
@@ -85,7 +85,7 @@ module Gitlab
private
private
NAME_STR
=
Gitlab
::
Regex
::
NAMESPACE_REGEX_STR
NAME_STR
=
Gitlab
::
Regex
::
NAMESPACE_
PATH_
REGEX_STR
PROJ_STR
=
"(?<project>
#{
NAME_STR
}
/
#{
NAME_STR
}
)"
PROJ_STR
=
"(?<project>
#{
NAME_STR
}
/
#{
NAME_STR
}
)"
REFERENCE_PATTERN
=
%r{
REFERENCE_PATTERN
=
%r{
...
...
lib/gitlab/regex.rb
View file @
c0116926
...
@@ -2,13 +2,13 @@ module Gitlab
...
@@ -2,13 +2,13 @@ module Gitlab
module
Regex
module
Regex
extend
self
extend
self
NAMESPACE_REGEX_STR
=
'(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'
.
freeze
NAMESPACE_
PATH_
REGEX_STR
=
'(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'
.
freeze
def
namespace_regex
def
namespace_
path_
regex
@namespace_
regex
||=
/\A
#{
NAMESPACE
_REGEX_STR
}
\z/
.
freeze
@namespace_
path_regex
||=
/\A
#{
NAMESPACE_PATH
_REGEX_STR
}
\z/
.
freeze
end
end
def
namespace_regex_message
def
namespace_
path_
regex_message
"can contain only letters, digits, '_', '-' and '.'. "
\
"can contain only letters, digits, '_', '-' and '.'. "
\
"Cannot start with '-' or end in '.'."
\
"Cannot start with '-' or end in '.'."
\
end
end
...
...
spec/requests/api/users_spec.rb
View file @
c0116926
...
@@ -145,7 +145,7 @@ describe API::API, api: true do
...
@@ -145,7 +145,7 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
][
'projects_limit'
]).
expect
(
json_response
[
'message'
][
'projects_limit'
]).
to
eq
([
'must be greater than or equal to 0'
])
to
eq
([
'must be greater than or equal to 0'
])
expect
(
json_response
[
'message'
][
'username'
]).
expect
(
json_response
[
'message'
][
'username'
]).
to
eq
([
Gitlab
::
Regex
.
send
(
:namespace_regex_message
)])
to
eq
([
Gitlab
::
Regex
.
send
(
:namespace_
path_
regex_message
)])
end
end
it
"shouldn't available for non admin users"
do
it
"shouldn't available for non admin users"
do
...
@@ -271,7 +271,7 @@ describe API::API, api: true do
...
@@ -271,7 +271,7 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
][
'projects_limit'
]).
expect
(
json_response
[
'message'
][
'projects_limit'
]).
to
eq
([
'must be greater than or equal to 0'
])
to
eq
([
'must be greater than or equal to 0'
])
expect
(
json_response
[
'message'
][
'username'
]).
expect
(
json_response
[
'message'
][
'username'
]).
to
eq
([
Gitlab
::
Regex
.
send
(
:namespace_regex_message
)])
to
eq
([
Gitlab
::
Regex
.
send
(
:namespace_
path_
regex_message
)])
end
end
context
"with existing user"
do
context
"with existing user"
do
...
...
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