BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
07c149de
Commit
07c149de
authored
Apr 17, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-username-period-migration' into 'master'
Fix username period migration to preserve uniqueness of names and paths. See merge request !534
parents
5456b00f
46524ecb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
namespace.rb
app/models/namespace.rb
+1
-0
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 @
07c149de
...
@@ -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 @
07c149de
...
@@ -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