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
Jérome Perrin
gitlab-ce
Commits
46524ecb
Commit
46524ecb
authored
Apr 17, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix username period migration to preserve uniqueness of names and paths.
parent
5456b00f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
app/models/namespace.rb
app/models/namespace.rb
+1
-0
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
...ate/20150324133047_remove_periods_at_ends_of_usernames.rb
+5
-5
No files found.
app/models/namespace.rb
View file @
46524ecb
...
...
@@ -59,6 +59,7 @@ class Namespace < ActiveRecord::Base
end
def
clean_path
(
path
)
path
=
path
.
dup
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\A-+/
,
""
)
...
...
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
View file @
46524ecb
...
...
@@ -3,21 +3,21 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
class
Namespace
<
ActiveRecord
::
Base
class
<<
self
def
by_path
(
path
)
where
(
'lower(path) = :value'
,
value:
path
.
downcase
).
first
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-
+/
,
""
)
path
.
gsub!
(
/
\.+\z/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
counter
=
0
base
=
path
while
Namespace
.
by_path
(
path
).
present?
while
Namespace
.
find_by_path_or_name
(
path
)
counter
+=
1
path
=
"
#{
base
}#{
counter
}
"
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