Commit 5f839770 authored by Douwe Maan's avatar Douwe Maan

Revert "Rename namespace_regex to namespace_path_regex."

This reverts commit c0116926.
parent 70f9893e
...@@ -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_path_regex, format: { with: Gitlab::Regex.namespace_regex,
message: Gitlab::Regex.namespace_path_regex_message } message: Gitlab::Regex.namespace_regex_message }
delegate :name, to: :owner, allow_nil: true, prefix: true delegate :name, to: :owner, allow_nil: true, prefix: true
......
...@@ -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_path_regex, format: { with: Gitlab::Regex.namespace_regex,
message: Gitlab::Regex.namespace_path_regex_message } message: Gitlab::Regex.namespace_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? }
......
...@@ -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_PATH_REGEX_STR NAMING_PATTERN = Gitlab::Regex::NAMESPACE_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
......
...@@ -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_PATH_REGEX_STR})/ USER_PATTERN = /@(?<user>#{Gitlab::Regex::NAMESPACE_REGEX_STR})/
def call def call
replace_text_nodes_matching(USER_PATTERN) do |content| replace_text_nodes_matching(USER_PATTERN) do |content|
......
...@@ -85,7 +85,7 @@ module Gitlab ...@@ -85,7 +85,7 @@ module Gitlab
private private
NAME_STR = Gitlab::Regex::NAMESPACE_PATH_REGEX_STR NAME_STR = Gitlab::Regex::NAMESPACE_REGEX_STR
PROJ_STR = "(?<project>#{NAME_STR}/#{NAME_STR})" PROJ_STR = "(?<project>#{NAME_STR}/#{NAME_STR})"
REFERENCE_PATTERN = %r{ REFERENCE_PATTERN = %r{
......
...@@ -2,13 +2,13 @@ module Gitlab ...@@ -2,13 +2,13 @@ module Gitlab
module Regex module Regex
extend self extend self
NAMESPACE_PATH_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'.freeze NAMESPACE_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'.freeze
def namespace_path_regex def namespace_regex
@namespace_path_regex ||= /\A#{NAMESPACE_PATH_REGEX_STR}\z/.freeze @namespace_regex ||= /\A#{NAMESPACE_REGEX_STR}\z/.freeze
end end
def namespace_path_regex_message def namespace_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
......
...@@ -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_path_regex_message)]) to eq([Gitlab::Regex.send(:namespace_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_path_regex_message)]) to eq([Gitlab::Regex.send(:namespace_regex_message)])
end end
context "with existing user" do context "with existing user" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment