ignore hashed repos (for now) when using rake gitlab:cleanup:repos
This commit is contained in:
parent
04c438065c
commit
5e861a0525
2 changed files with 45 additions and 1 deletions
|
@ -59,7 +59,10 @@ namespace :gitlab do
|
||||||
.sub(%r{^/*}, '')
|
.sub(%r{^/*}, '')
|
||||||
.chomp('.git')
|
.chomp('.git')
|
||||||
.chomp('.wiki')
|
.chomp('.wiki')
|
||||||
next if Project.find_by_full_path(repo_with_namespace)
|
|
||||||
|
# TODO ignoring hashed repositories for now. But revisit to fully support
|
||||||
|
# possible orphaned hashed repos
|
||||||
|
next if repo_with_namespace.start_with?('@hashed/') || Project.find_by_full_path(repo_with_namespace)
|
||||||
|
|
||||||
new_path = path + move_suffix
|
new_path = path + move_suffix
|
||||||
puts path.inspect + ' -> ' + new_path.inspect
|
puts path.inspect + ' -> ' + new_path.inspect
|
||||||
|
|
41
spec/tasks/gitlab/cleanup_rake_spec.rb
Normal file
41
spec/tasks/gitlab/cleanup_rake_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
require 'rake_helper'
|
||||||
|
|
||||||
|
describe 'gitlab:cleanup rake tasks' do
|
||||||
|
before do
|
||||||
|
Rake.application.rake_require 'tasks/gitlab/cleanup'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'cleanup repositories' do
|
||||||
|
let(:gitaly_address) { Gitlab.config.repositories.storages.default.gitaly_address }
|
||||||
|
let(:storages) do
|
||||||
|
{
|
||||||
|
'default' => { 'path' => Settings.absolute('tmp/tests/default_storage'), 'gitaly_address' => gitaly_address }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
FileUtils.mkdir(Settings.absolute('tmp/tests/default_storage'))
|
||||||
|
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'moves it to an orphaned path' do
|
||||||
|
FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/broken/project.git'))
|
||||||
|
run_rake_task('gitlab:cleanup:repos')
|
||||||
|
repo_list = Dir['tmp/tests/default_storage/broken/*']
|
||||||
|
|
||||||
|
expect(repo_list.first).to include('+orphaned+')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'ignores @hashed repos' do
|
||||||
|
FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
Loading…
Reference in a new issue