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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b6d01abc
Commit
b6d01abc
authored
Apr 17, 2015
by
Douwe Maan
Committed by
Dmitriy Zaporozhets
Apr 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix username period migration to preserve uniqueness of names and paths.
parent
743f3ed6
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 @
b6d01abc
...
@@ -59,6 +59,7 @@ class Namespace < ActiveRecord::Base
...
@@ -59,6 +59,7 @@ class Namespace < ActiveRecord::Base
end
end
def
clean_path
(
path
)
def
clean_path
(
path
)
path
=
path
.
dup
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\A-+/
,
""
)
path
.
gsub!
(
/\A-+/
,
""
)
...
...
db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
View file @
b6d01abc
...
@@ -3,21 +3,21 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
...
@@ -3,21 +3,21 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
class
Namespace
<
ActiveRecord
::
Base
class
Namespace
<
ActiveRecord
::
Base
class
<<
self
class
<<
self
def
by_path
(
path
)
def
find_by_path_or_name
(
path
)
where
(
'lower(path) = :value'
,
value:
path
.
downcase
).
first
find_by
(
"lower(path) = :path OR lower(name) = :path"
,
path:
path
.
downcase
)
end
end
def
clean_path
(
path
)
def
clean_path
(
path
)
path
=
path
.
dup
path
=
path
.
dup
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\A-
/
,
""
)
path
.
gsub!
(
/\A-
+/
,
""
)
path
.
gsub!
(
/
.\z/
,
""
)
path
.
gsub!
(
/
\.+\z/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
counter
=
0
counter
=
0
base
=
path
base
=
path
while
Namespace
.
by_path
(
path
).
present?
while
Namespace
.
find_by_path_or_name
(
path
)
counter
+=
1
counter
+=
1
path
=
"
#{
base
}#{
counter
}
"
path
=
"
#{
base
}#{
counter
}
"
end
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