summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-24 15:16:38 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-24 15:16:38 +0200
commit5f839770e720dc2f176c51d4635dceb6c34ff97a (patch)
tree396578cfe0a4ddb7df0adf176bfce3a6e2bf2905
parent70f9893ed697873e4c95de4f3ddb3ff8c4fb82f6 (diff)
downloadgitlab-ce-5f839770e720dc2f176c51d4635dceb6c34ff97a.tar.gz
Revert "Rename namespace_regex to namespace_path_regex."
This reverts commit c0116926c743818b2593474946abb40b56d8fefa.
-rw-r--r--app/models/namespace.rb4
-rw-r--r--app/models/user.rb4
-rw-r--r--lib/gitlab/markdown/cross_project_reference.rb2
-rw-r--r--lib/gitlab/markdown/user_reference_filter.rb2
-rw-r--r--lib/gitlab/reference_extractor.rb2
-rw-r--r--lib/gitlab/regex.rb8
-rw-r--r--spec/requests/api/users_spec.rb4
7 files changed, 13 insertions, 13 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index f51a14a9514..211dfa76b81 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -33,8 +33,8 @@ class Namespace < ActiveRecord::Base
presence: true,
length: { within: 1..255 },
exclusion: { in: Gitlab::Blacklist.path },
- format: { with: Gitlab::Regex.namespace_path_regex,
- message: Gitlab::Regex.namespace_path_regex_message }
+ format: { with: Gitlab::Regex.namespace_regex,
+ message: Gitlab::Regex.namespace_regex_message }
delegate :name, to: :owner, allow_nil: true, prefix: true
diff --git a/app/models/user.rb b/app/models/user.rb
index 7d7faa64f72..d6b93afe739 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -131,8 +131,8 @@ class User < ActiveRecord::Base
presence: true,
uniqueness: { case_sensitive: false },
exclusion: { in: Gitlab::Blacklist.path },
- format: { with: Gitlab::Regex.namespace_path_regex,
- message: Gitlab::Regex.namespace_path_regex_message }
+ format: { with: Gitlab::Regex.namespace_regex,
+ message: Gitlab::Regex.namespace_regex_message }
validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true
validate :namespace_uniq, if: ->(user) { user.username_changed? }
diff --git a/lib/gitlab/markdown/cross_project_reference.rb b/lib/gitlab/markdown/cross_project_reference.rb
index 261fc0feb0e..c436fabd658 100644
--- a/lib/gitlab/markdown/cross_project_reference.rb
+++ b/lib/gitlab/markdown/cross_project_reference.rb
@@ -3,7 +3,7 @@ module Gitlab
# Common methods for ReferenceFilters that support an optional cross-project
# reference.
module CrossProjectReference
- NAMING_PATTERN = Gitlab::Regex::NAMESPACE_PATH_REGEX_STR
+ NAMING_PATTERN = Gitlab::Regex::NAMESPACE_REGEX_STR
PROJECT_PATTERN = "(?<project>#{NAMING_PATTERN}/#{NAMING_PATTERN})"
# Given a cross-project reference string, get the Project record
diff --git a/lib/gitlab/markdown/user_reference_filter.rb b/lib/gitlab/markdown/user_reference_filter.rb
index d7885fdeefd..5fc8ed55fe2 100644
--- a/lib/gitlab/markdown/user_reference_filter.rb
+++ b/lib/gitlab/markdown/user_reference_filter.rb
@@ -22,7 +22,7 @@ module Gitlab
end
# 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
replace_text_nodes_matching(USER_PATTERN) do |content|
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index 1d6df9a29f1..949dd5d26b1 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -85,7 +85,7 @@ module Gitlab
private
- NAME_STR = Gitlab::Regex::NAMESPACE_PATH_REGEX_STR
+ NAME_STR = Gitlab::Regex::NAMESPACE_REGEX_STR
PROJ_STR = "(?<project>#{NAME_STR}/#{NAME_STR})"
REFERENCE_PATTERN = %r{
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb
index e5f5482a223..0571574aa4f 100644
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
@@ -2,13 +2,13 @@ module Gitlab
module Regex
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
- @namespace_path_regex ||= /\A#{NAMESPACE_PATH_REGEX_STR}\z/.freeze
+ def namespace_regex
+ @namespace_regex ||= /\A#{NAMESPACE_REGEX_STR}\z/.freeze
end
- def namespace_path_regex_message
+ def namespace_regex_message
"can contain only letters, digits, '_', '-' and '.'. " \
"Cannot start with '-' or end in '.'." \
end
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index cb41ea44918..327f3e6d23c 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -145,7 +145,7 @@ describe API::API, api: true do
expect(json_response['message']['projects_limit']).
to eq(['must be greater than or equal to 0'])
expect(json_response['message']['username']).
- to eq([Gitlab::Regex.send(:namespace_path_regex_message)])
+ to eq([Gitlab::Regex.send(:namespace_regex_message)])
end
it "shouldn't available for non admin users" do
@@ -271,7 +271,7 @@ describe API::API, api: true do
expect(json_response['message']['projects_limit']).
to eq(['must be greater than or equal to 0'])
expect(json_response['message']['username']).
- to eq([Gitlab::Regex.send(:namespace_path_regex_message)])
+ to eq([Gitlab::Regex.send(:namespace_regex_message)])
end
context "with existing user" do