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
17069a95
Commit
17069a95
authored
Nov 24, 2017
by
digitalMoksha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignore hashed repositories when doing rake gitlab:cleanup:dirs
parent
b355ebc4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
11 deletions
+39
-11
lib/tasks/gitlab/cleanup.rake
lib/tasks/gitlab/cleanup.rake
+2
-1
spec/tasks/gitlab/cleanup_rake_spec.rb
spec/tasks/gitlab/cleanup_rake_spec.rb
+37
-10
No files found.
lib/tasks/gitlab/cleanup.rake
View file @
17069a95
...
...
@@ -6,6 +6,7 @@ namespace :gitlab do
remove_flag
=
ENV
[
'REMOVE'
]
namespaces
=
Namespace
.
pluck
(
:path
)
namespaces
<<
'@hashed'
# add so that it will be ignored
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
name
,
repository_storage
|
git_base_path
=
repository_storage
[
'path'
]
all_dirs
=
Dir
.
glob
(
git_base_path
+
'/*'
)
...
...
spec/tasks/gitlab/cleanup_rake_spec.rb
View file @
17069a95
...
...
@@ -5,7 +5,8 @@ describe 'gitlab:cleanup rake tasks' do
Rake
.
application
.
rake_require
'tasks/gitlab/cleanup'
end
context
'cleanup repositories'
do
describe
'cleanup'
do
let
(
:gitaly_address
)
{
Gitlab
.
config
.
repositories
.
storages
.
default
.
gitaly_address
}
let
(
:storages
)
do
{
...
...
@@ -22,8 +23,13 @@ describe 'gitlab:cleanup rake tasks' do
FileUtils
.
rm_rf
(
Settings
.
absolute
(
'tmp/tests/default_storage'
))
end
it
'moves it to an orphaned path'
do
describe
'cleanup:repos'
do
before
do
FileUtils
.
mkdir_p
(
Settings
.
absolute
(
'tmp/tests/default_storage/broken/project.git'
))
FileUtils
.
mkdir_p
(
Settings
.
absolute
(
'tmp/tests/default_storage/@hashed/12/34/5678.git'
))
end
it
'moves it to an orphaned path'
do
run_rake_task
(
'gitlab:cleanup:repos'
)
repo_list
=
Dir
[
'tmp/tests/default_storage/broken/*'
]
...
...
@@ -31,11 +37,32 @@ describe 'gitlab:cleanup rake tasks' do
end
it
'ignores @hashed repos'
do
run_rake_task
(
'gitlab:cleanup:repos'
)
expect
(
Dir
.
exist?
(
Settings
.
absolute
(
'tmp/tests/default_storage/@hashed/12/34/5678.git'
))).
to
be_truthy
end
end
describe
'cleanup:dirs'
do
it
'removes missing namespaces'
do
FileUtils
.
mkdir_p
(
Settings
.
absolute
(
"tmp/tests/default_storage/namespace_1/project.git"
))
FileUtils
.
mkdir_p
(
Settings
.
absolute
(
"tmp/tests/default_storage/namespace_2/project.git"
))
allow
(
Namespace
).
to
receive
(
:pluck
).
and_return
(
'namespace_1'
)
stub_env
(
'REMOVE'
,
'true'
)
run_rake_task
(
'gitlab:cleanup:dirs'
)
expect
(
Dir
.
exist?
(
Settings
.
absolute
(
'tmp/tests/default_storage/namespace_1'
))).
to
be_truthy
expect
(
Dir
.
exist?
(
Settings
.
absolute
(
'tmp/tests/default_storage/namespace_2'
))).
to
be_falsey
end
it
'ignores @hashed directory'
do
FileUtils
.
mkdir_p
(
Settings
.
absolute
(
'tmp/tests/default_storage/@hashed/12/34/5678.git'
))
run_rake_task
(
'gitlab:cleanup:repo
s'
)
run_rake_task
(
'gitlab:cleanup:dir
s'
)
expect
(
Dir
.
exist?
(
Settings
.
absolute
(
'tmp/tests/default_storage/@hashed/12/34/5678.git'
))).
to
be_truthy
end
end
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