diff options
author | Stan Hu <stanhu@gmail.com> | 2017-11-21 20:26:53 +0000 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2017-11-21 21:31:40 +0100 |
commit | e1bee8e7c9fca21384903b7c2f270d806d6cc15c (patch) | |
tree | 55cfacc9a389a3fa7f7ee349487e9682ec795a39 | |
parent | 5fe4a302ef25894fb26782c7cb57e96eaf0ea706 (diff) | |
download | gitlab-ce-e1bee8e7c9fca21384903b7c2f270d806d6cc15c.tar.gz |
Merge branch '40291-ignore-hashed-repos-cleanup-repositories' into 'master'
ignore hashed repos (for now) when using `rake gitlab:cleanup:repos`
Closes #40291
See merge request gitlab-org/gitlab-ce!15520
(cherry picked from commit b462edfddbd8e8b4449a6ae8cf482a9255f5d550)
Conflicts:
lib/tasks/gitlab/cleanup.rake
-rw-r--r-- | lib/tasks/gitlab/cleanup.rake | 8 | ||||
-rw-r--r-- | spec/tasks/gitlab/cleanup_rake_spec.rb | 41 |
2 files changed, 49 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake index 8ae1b6a626a..a1a569cf8ee 100644 --- a/lib/tasks/gitlab/cleanup.rake +++ b/lib/tasks/gitlab/cleanup.rake @@ -59,7 +59,15 @@ namespace :gitlab do .sub(%r{^/*}, '') .chomp('.git') .chomp('.wiki') +<<<<<<< HEAD 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) + +>>>>>>> b462edfddb... Merge branch '40291-ignore-hashed-repos-cleanup-repositories' into 'master' new_path = path + move_suffix puts path.inspect + ' -> ' + new_path.inspect File.rename(path, new_path) diff --git a/spec/tasks/gitlab/cleanup_rake_spec.rb b/spec/tasks/gitlab/cleanup_rake_spec.rb new file mode 100644 index 00000000000..641eccfd334 --- /dev/null +++ b/spec/tasks/gitlab/cleanup_rake_spec.rb @@ -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 |