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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-ce
Commits
1d2a5ee1
Commit
1d2a5ee1
authored
Apr 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert disallowing usernames to end in period."
This reverts commit
c75c6b84
.
parent
6ae606d8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
2 deletions
+79
-2
CHANGELOG
CHANGELOG
+1
-0
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
...ate/20150324133047_remove_periods_at_ends_of_usernames.rb
+76
-0
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+2
-2
No files found.
CHANGELOG
View file @
1d2a5ee1
...
...
@@ -97,6 +97,7 @@ v 7.10.0 (unreleased)
- Fix admin user projects lists.
- Don't leak private group existence by redirecting from namespace controller to group controller.
- Ability to skip some items from backup (database, respositories or uploads)
- Fix "Hello @username." references not working by no longer allowing usernames to end in period.
- Archive repositories in background worker.
- Import GitHub, Bitbucket or GitLab.com projects owned by authenticated user into current namespace.
- Project labels are now available over the API under the "tag_list" field (Cristian Medina)
...
...
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
0 → 100644
View file @
1d2a5ee1
class
RemovePeriodsAtEndsOfUsernames
<
ActiveRecord
::
Migration
include
Gitlab
::
ShellAdapter
class
Namespace
<
ActiveRecord
::
Base
class
<<
self
def
find_by_path_or_name
(
path
)
find_by
(
"lower(path) = :path OR lower(name) = :path"
,
path:
path
.
downcase
)
end
def
clean_path
(
path
)
path
=
path
.
dup
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\A-+/
,
""
)
path
.
gsub!
(
/\.+\z/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
counter
=
0
base
=
path
while
Namespace
.
find_by_path_or_name
(
path
)
counter
+=
1
path
=
"
#{
base
}#{
counter
}
"
end
path
end
end
end
def
up
changed_paths
=
{}
select_all
(
"SELECT id, username FROM users WHERE username LIKE '%.'"
).
each
do
|
user
|
username_was
=
user
[
"username"
]
username
=
Namespace
.
clean_path
(
username_was
)
changed_paths
[
username_was
]
=
username
username
=
quote_string
(
username
)
execute
"UPDATE users SET username = '
#{
username
}
' WHERE id =
#{
user
[
"id"
]
}
"
execute
"UPDATE namespaces SET path = '
#{
username
}
', name = '
#{
username
}
' WHERE type IS NULL AND owner_id =
#{
user
[
"id"
]
}
"
end
select_all
(
"SELECT id, path FROM namespaces WHERE type = 'Group' AND path LIKE '%.'"
).
each
do
|
group
|
path_was
=
group
[
"path"
]
path
=
Namespace
.
clean_path
(
path_was
)
changed_paths
[
path_was
]
=
path
path
=
quote_string
(
path
)
execute
"UPDATE namespaces SET path = '
#{
path
}
' WHERE id =
#{
group
[
"id"
]
}
"
end
changed_paths
.
each
do
|
path_was
,
path
|
if
gitlab_shell
.
mv_namespace
(
path_was
,
path
)
# If repositories moved successfully we need to remove old satellites
# and send update instructions to users.
# However we cannot allow rollback since we moved namespace dir
# So we basically we mute exceptions in next actions
begin
gitlab_shell
.
rm_satellites
(
path_was
)
# We cannot send update instructions since models and mailers
# can't safely be used from migrations as they may be written for
# later versions of the database.
# send_update_instructions
rescue
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
false
end
else
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise
Exception
.
new
(
'namespace directory cannot be moved'
)
end
end
end
end
lib/gitlab/regex.rb
View file @
1d2a5ee1
...
...
@@ -2,7 +2,7 @@ module Gitlab
module
Regex
extend
self
NAMESPACE_REGEX_STR
=
'(?:[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_regex
@namespace_regex
||=
/\A
#{
NAMESPACE_REGEX_STR
}
\z/
.
freeze
...
...
@@ -10,7 +10,7 @@ module Gitlab
def
namespace_regex_message
"can contain only letters, digits, '_', '-' and '.'. "
\
"Cannot start with '-'."
\
"Cannot start with '-'
or end in '.'
."
\
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