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
Léo-Paul Géneau
gitlab-ce
Commits
3e84b633
Commit
3e84b633
authored
Jun 06, 2017
by
Bob Van Landuyt
Committed by
Bob Van Landuyt
Jun 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track all renames in redis
parent
36ecbb69
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
0 deletions
+44
-0
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
...atabase/rename_reserved_paths_migration/v1/rename_base.rb
+5
-0
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
...e/rename_reserved_paths_migration/v1/rename_namespaces.rb
+2
-0
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb
...ase/rename_reserved_paths_migration/v1/rename_projects.rb
+2
-0
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
...se/rename_reserved_paths_migration/v1/rename_base_spec.rb
+17
-0
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
...ame_reserved_paths_migration/v1/rename_namespaces_spec.rb
+7
-0
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb
...ename_reserved_paths_migration/v1/rename_projects_spec.rb
+7
-0
spec/support/fake_migration_classes.rb
spec/support/fake_migration_classes.rb
+4
-0
No files found.
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
View file @
3e84b633
...
...
@@ -114,6 +114,11 @@ module Gitlab
end
end
def
track_rename
(
type
,
old_path
,
new_path
)
key
=
"rename:
#{
migration
.
version
}
:
#{
type
}
"
Gitlab
::
Redis
.
with
{
|
redis
|
redis
.
lpush
(
key
,
[
old_path
,
new_path
].
to_json
)
}
end
def
file_storage?
CarrierWave
::
Uploader
::
Base
.
storage
==
CarrierWave
::
Storage
::
File
end
...
...
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
View file @
3e84b633
...
...
@@ -26,6 +26,8 @@ module Gitlab
def
rename_namespace
(
namespace
)
old_full_path
,
new_full_path
=
rename_path_for_routable
(
namespace
)
track_rename
(
'namespace'
,
old_full_path
,
new_full_path
)
move_repositories
(
namespace
,
old_full_path
,
new_full_path
)
move_uploads
(
old_full_path
,
new_full_path
)
move_pages
(
old_full_path
,
new_full_path
)
...
...
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb
View file @
3e84b633
...
...
@@ -16,6 +16,8 @@ module Gitlab
def
rename_project
(
project
)
old_full_path
,
new_full_path
=
rename_path_for_routable
(
project
)
track_rename
(
'project'
,
old_full_path
,
new_full_path
)
move_repository
(
project
,
old_full_path
,
new_full_path
)
move_repository
(
project
,
"
#{
old_full_path
}
.wiki"
,
"
#{
new_full_path
}
.wiki"
)
move_uploads
(
old_full_path
,
new_full_path
)
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
View file @
3e84b633
...
...
@@ -203,4 +203,21 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :trunca
expect
(
File
.
exist?
(
expected_file
)).
to
be
(
true
)
end
end
describe
'#track_rename'
,
redis:
true
do
it
'tracks a rename in redis'
do
key
=
'rename:20170316163845:namespace'
subject
.
track_rename
(
'namespace'
,
'path/to/namespace'
,
'path/to/renamed'
)
old_path
,
new_path
=
[
nil
,
nil
]
Gitlab
::
Redis
.
with
do
|
redis
|
rename_info
=
redis
.
lpop
(
key
)
old_path
,
new_path
=
JSON
.
parse
(
rename_info
)
end
expect
(
old_path
).
to
eq
(
'path/to/namespace'
)
expect
(
new_path
).
to
eq
(
'path/to/renamed'
)
end
end
end
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
View file @
3e84b633
...
...
@@ -191,6 +191,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
subject
.
rename_namespace
(
user
.
namespace
)
end
it
'tracks the rename'
do
expect
(
subject
).
to
receive
(
:track_rename
)
.
with
(
'namespace'
,
'the-path'
,
'the-path0'
)
subject
.
rename_namespace
(
namespace
)
end
end
describe
'#rename_user'
do
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb
View file @
3e84b633
...
...
@@ -85,6 +85,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :tr
subject
.
rename_project
(
project
)
end
it
'tracks the rename'
do
expect
(
subject
).
to
receive
(
:track_rename
)
.
with
(
'project'
,
'known-parent/the-path'
,
'known-parent/the-path0'
)
subject
.
rename_project
(
project
)
end
end
describe
'#move_repository'
do
...
...
spec/support/fake_migration_classes.rb
View file @
3e84b633
class
FakeRenameReservedPathMigrationV1
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
RenameReservedPathsMigration
::
V1
def
version
'20170316163845'
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