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
39efd0c0
Commit
39efd0c0
authored
Apr 19, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear cached markdown after renaming projects
parent
389057f0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
6 deletions
+88
-6
lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb
...b/database/rename_reserved_paths_migration/rename_base.rb
+18
-0
lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb
...base/rename_reserved_paths_migration/rename_namespaces.rb
+1
-2
lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb
...tabase/rename_reserved_paths_migration/rename_projects.rb
+5
-1
spec/lib/gitlab/database/rename_reserved_paths_migration/rename_base_spec.rb
...abase/rename_reserved_paths_migration/rename_base_spec.rb
+40
-0
spec/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces_spec.rb
...rename_reserved_paths_migration/rename_namespaces_spec.rb
+7
-1
spec/lib/gitlab/database/rename_reserved_paths_migration/rename_projects_spec.rb
...e/rename_reserved_paths_migration/rename_projects_spec.rb
+17
-2
No files found.
lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb
View file @
39efd0c0
...
@@ -90,6 +90,24 @@ module Gitlab
...
@@ -90,6 +90,24 @@ module Gitlab
FileUtils
.
mv
(
old_path
,
new_path
)
FileUtils
.
mv
(
old_path
,
new_path
)
end
end
def
remove_cached_html_for_projects
(
project_ids
)
update_column_in_batches
(
:projects
,
:description_html
,
nil
)
do
|
table
,
query
|
query
.
where
(
table
[
:id
].
in
(
project_ids
))
end
update_column_in_batches
(
:issues
,
:description_html
,
nil
)
do
|
table
,
query
|
query
.
where
(
table
[
:project_id
].
in
(
project_ids
))
end
update_column_in_batches
(
:merge_requests
,
:description_html
,
nil
)
do
|
table
,
query
|
query
.
where
(
table
[
:target_project_id
].
in
(
project_ids
))
end
update_column_in_batches
(
:notes
,
:note_html
,
nil
)
do
|
table
,
query
|
query
.
where
(
table
[
:project_id
].
in
(
project_ids
))
end
end
def
file_storage?
def
file_storage?
CarrierWave
::
Uploader
::
Base
.
storage
==
CarrierWave
::
Storage
::
File
CarrierWave
::
Uploader
::
Base
.
storage
==
CarrierWave
::
Storage
::
File
end
end
...
...
lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb
View file @
39efd0c0
...
@@ -27,6 +27,7 @@ module Gitlab
...
@@ -27,6 +27,7 @@ module Gitlab
move_repositories
(
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_uploads
(
old_full_path
,
new_full_path
)
move_pages
(
old_full_path
,
new_full_path
)
move_pages
(
old_full_path
,
new_full_path
)
remove_cached_html_for_projects
(
projects_for_namespace
(
namespace
).
map
(
&
:id
))
end
end
def
move_repositories
(
namespace
,
old_full_path
,
new_full_path
)
def
move_repositories
(
namespace
,
old_full_path
,
new_full_path
)
...
@@ -55,8 +56,6 @@ module Gitlab
...
@@ -55,8 +56,6 @@ module Gitlab
MigrationClasses
::
Project
.
where
(
namespace_or_children
)
MigrationClasses
::
Project
.
where
(
namespace_or_children
)
end
end
# This won't scale to huge trees, but it should do for a handful of
# namespaces called `system`.
def
child_ids_for_parent
(
namespace
,
ids:
[])
def
child_ids_for_parent
(
namespace
,
ids:
[])
namespace
.
children
.
each
do
|
child
|
namespace
.
children
.
each
do
|
child
|
ids
<<
child
.
id
ids
<<
child
.
id
...
...
lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb
View file @
39efd0c0
...
@@ -8,6 +8,8 @@ module Gitlab
...
@@ -8,6 +8,8 @@ module Gitlab
projects_for_paths
.
each
do
|
project
|
projects_for_paths
.
each
do
|
project
|
rename_project
(
project
)
rename_project
(
project
)
end
end
remove_cached_html_for_projects
(
projects_for_paths
.
map
(
&
:id
))
end
end
def
rename_project
(
project
)
def
rename_project
(
project
)
...
@@ -28,10 +30,12 @@ module Gitlab
...
@@ -28,10 +30,12 @@ module Gitlab
end
end
def
projects_for_paths
def
projects_for_paths
return
@projects_for_paths
if
@projects_for_paths
with_paths
=
MigrationClasses
::
Route
.
arel_table
[
:path
]
with_paths
=
MigrationClasses
::
Route
.
arel_table
[
:path
]
.
matches_any
(
path_patterns
)
.
matches_any
(
path_patterns
)
MigrationClasses
::
Project
.
joins
(
:route
).
where
(
with_paths
)
@projects_for_paths
=
MigrationClasses
::
Project
.
joins
(
:route
).
where
(
with_paths
)
end
end
end
end
end
end
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/rename_base_spec.rb
View file @
39efd0c0
...
@@ -27,6 +27,46 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameBase do
...
@@ -27,6 +27,46 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameBase do
end
end
end
end
describe
'#remove_cached_html_for_projects'
do
let
(
:project
)
{
create
(
:empty_project
,
description_html:
'Project description'
)
}
it
'removes description_html from projects'
do
subject
.
remove_cached_html_for_projects
([
project
.
id
])
expect
(
project
.
reload
.
description_html
).
to
be_nil
end
it
'removes issue descriptions'
do
issue
=
create
(
:issue
,
project:
project
,
description_html:
'Issue description'
)
subject
.
remove_cached_html_for_projects
([
project
.
id
])
expect
(
issue
.
reload
.
description_html
).
to
be_nil
end
it
'removes merge request descriptions'
do
merge_request
=
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
description_html:
'MergeRequest description'
)
subject
.
remove_cached_html_for_projects
([
project
.
id
])
expect
(
merge_request
.
reload
.
description_html
).
to
be_nil
end
it
'removes note html'
do
note
=
create
(
:note
,
project:
project
,
noteable:
create
(
:issue
,
project:
project
),
note_html:
'note description'
)
subject
.
remove_cached_html_for_projects
([
project
.
id
])
expect
(
note
.
reload
.
note_html
).
to
be_nil
end
end
describe
'#rename_path_for_routable'
do
describe
'#rename_path_for_routable'
do
context
'for namespaces'
do
context
'for namespaces'
do
let
(
:namespace
)
{
create
(
:namespace
,
path:
'the-path'
)
}
let
(
:namespace
)
{
create
(
:namespace
,
path:
'the-path'
)
}
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces_spec.rb
View file @
39efd0c0
...
@@ -139,7 +139,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameNamespaces do
...
@@ -139,7 +139,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameNamespaces do
subject
.
rename_namespace
(
namespace
)
subject
.
rename_namespace
(
namespace
)
end
end
it
'invalidates the markdown cache of related projects'
it
'invalidates the markdown cache of related projects'
do
project
=
create
(
:empty_project
,
namespace:
namespace
,
path:
"the-path-project"
)
expect
(
subject
).
to
receive
(
:remove_cached_html_for_projects
).
with
([
project
.
id
])
subject
.
rename_namespace
(
namespace
)
end
end
end
describe
'#rename_namespaces'
do
describe
'#rename_namespaces'
do
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/rename_projects_spec.rb
View file @
39efd0c0
...
@@ -29,6 +29,23 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameProjects do
...
@@ -29,6 +29,23 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameProjects do
end
end
end
end
describe
'#rename_projects'
do
let!
(
:projects
)
{
create_list
(
:empty_project
,
2
,
path:
'the-path'
)
}
it
'renames each project'
do
expect
(
subject
).
to
receive
(
:rename_project
).
twice
subject
.
rename_projects
end
it
'invalidates the markdown cache of related projects'
do
expect
(
subject
).
to
receive
(
:remove_cached_html_for_projects
).
with
(
projects
.
map
(
&
:id
))
subject
.
rename_projects
end
end
describe
'#rename_project'
do
describe
'#rename_project'
do
let
(
:project
)
do
let
(
:project
)
do
create
(
:empty_project
,
create
(
:empty_project
,
...
@@ -68,8 +85,6 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameProjects do
...
@@ -68,8 +85,6 @@ describe Gitlab::Database::RenameReservedPathsMigration::RenameProjects do
subject
.
rename_project
(
project
)
subject
.
rename_project
(
project
)
end
end
it
'invalidates the markdown cache of related projects'
end
end
describe
'#move_repository'
do
describe
'#move_repository'
do
...
...
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