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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
fac1f83f
Commit
fac1f83f
authored
Apr 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly migrate users with usernames like "." or "..".
parent
c0116926
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
app/models/namespace.rb
app/models/namespace.rb
+5
-1
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
...ate/20150324133047_remove_periods_at_ends_of_usernames.rb
+4
-0
No files found.
app/models/namespace.rb
View file @
fac1f83f
...
...
@@ -66,9 +66,13 @@ class Namespace < ActiveRecord::Base
path
.
gsub!
(
/\.+\z/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
# Users with the great usernames of "." or ".." would end up with a blank username.
# Work around that by setting their username to "blank", followed by a counter.
path
=
"blank"
if
path
.
blank?
counter
=
0
base
=
path
while
Namespace
.
by_path
(
path
).
present?
while
Namespace
.
find_by_path_or_name
(
path
)
counter
+=
1
path
=
"
#{
base
}#{
counter
}
"
end
...
...
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
View file @
fac1f83f
...
...
@@ -15,6 +15,10 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
path
.
gsub!
(
/\.+\z/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
# Users with the great usernames of "." or ".." would end up with a blank username.
# Work around that by setting their username to "blank", followed by a counter.
path
=
"blank"
if
path
.
blank?
counter
=
0
base
=
path
while
Namespace
.
find_by_path_or_name
(
path
)
...
...
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