summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2014-06-26 09:53:01 +0200
committerCiro Santilli <ciro.santilli@gmail.com>2014-06-26 13:31:34 +0200
commitb1c40e81510ccccc5e93a82d2f5b819d6dea69e5 (patch)
treef597169e68893bb35cf1b1a8a36d355a097c8293 /app
parent3f8e6cf3d1360ce0843e4fd8f9c04040aba2baae (diff)
downloadgitlab-ce-b1c40e81510ccccc5e93a82d2f5b819d6dea69e5.tar.gz
Fix username validation message to match regexp.
Also used for project, group and web ui new file names.
Diffstat (limited to 'app')
-rw-r--r--app/models/namespace.rb4
-rw-r--r--app/models/project.rb4
-rw-r--r--app/models/user.rb2
-rw-r--r--app/services/files/create_service.rb5
4 files changed, 9 insertions, 6 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 446e5f04c63..fd973ddf226 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -25,12 +25,12 @@ class Namespace < ActiveRecord::Base
validates :name, presence: true, uniqueness: true,
length: { within: 0..255 },
format: { with: Gitlab::Regex.name_regex,
- message: "only letters, digits, spaces & '_' '-' '.' allowed." }
+ message: Gitlab::Regex.name_regex_message }
validates :description, length: { within: 0..255 }
validates :path, uniqueness: { case_sensitive: false }, presence: true, length: { within: 1..255 },
exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.path_regex,
- message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
+ message: Gitlab::Regex.path_regex_message }
delegate :name, to: :owner, allow_nil: true, prefix: true
diff --git a/app/models/project.rb b/app/models/project.rb
index 762b540b7a3..00e57a8a1c9 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -93,11 +93,11 @@ class Project < ActiveRecord::Base
validates :description, length: { maximum: 2000 }, allow_blank: true
validates :name, presence: true, length: { within: 0..255 },
format: { with: Gitlab::Regex.project_name_regex,
- message: "only letters, digits, spaces & '_' '-' '.' allowed. Letter or digit should be first" }
+ message: Gitlab::Regex.project_regex_message }
validates :path, presence: true, length: { within: 0..255 },
exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.path_regex,
- message: "only letters, digits & '_' '-' '.' allowed. Letter or digit should be first" }
+ message: Gitlab::Regex.path_regex_message }
validates :issues_enabled, :merge_requests_enabled,
:wiki_enabled, inclusion: { in: [true, false] }
validates :issues_tracker_id, length: { maximum: 255 }, allow_blank: true
diff --git a/app/models/user.rb b/app/models/user.rb
index 63d819a0f36..979fddb0cd1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -120,7 +120,7 @@ class User < ActiveRecord::Base
validates :username, presence: true, uniqueness: { case_sensitive: false },
exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.username_regex,
- message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
+ message: Gitlab::Regex.username_regex_message }
validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true
validate :namespace_uniq, if: ->(user) { user.username_changed? }
diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb
index 1998fb79e7d..82e4d7b684f 100644
--- a/app/services/files/create_service.rb
+++ b/app/services/files/create_service.rb
@@ -21,7 +21,10 @@ module Files
file_path = path
unless file_name =~ Gitlab::Regex.path_regex
- return error("Your changes could not be committed, because file name contains not allowed characters")
+ return error(
+ 'Your changes could not be committed, because the file name ' +
+ Gitlab::Regex.path_regex_message
+ )
end
blob = repository.blob_at_branch(ref, file_path)