When a project wiki is disabled skip it for fsck
This commit is contained in:
parent
6d899f46b5
commit
d7a4a2fe75
|
@ -15,10 +15,10 @@ module RepositoryCheck
|
|||
private
|
||||
|
||||
def check(project)
|
||||
repositories = [project.repository]
|
||||
repositories << project.wiki.repository if project.wiki_enabled?
|
||||
# Use 'map do', not 'all? do', to prevent short-circuiting
|
||||
[project.repository, project.wiki.repository].map do |repository|
|
||||
git_fsck(repository.path_to_repo)
|
||||
end.all?
|
||||
repositories.map { |repository| git_fsck(repository.path_to_repo) }.all?
|
||||
end
|
||||
|
||||
def git_fsck(path)
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
require 'spec_helper'
|
||||
require 'fileutils'
|
||||
|
||||
describe RepositoryCheck::SingleRepositoryWorker do
|
||||
subject { described_class.new }
|
||||
|
||||
it 'fails if the wiki repository is broken' do
|
||||
project = create(:project_empty_repo, wiki_enabled: true)
|
||||
project.create_wiki
|
||||
|
||||
# Test sanity: everything should be fine before the wiki repo is broken
|
||||
subject.perform(project.id)
|
||||
expect(project.reload.last_repository_check_failed).to eq(false)
|
||||
|
||||
FileUtils.rm_rf(project.wiki.repository.path_to_repo)
|
||||
subject.perform(project.id)
|
||||
|
||||
expect(project.reload.last_repository_check_failed).to eq(true)
|
||||
end
|
||||
|
||||
it 'skips wikis when disabled' do
|
||||
project = create(:project_empty_repo, wiki_enabled: false)
|
||||
# Make sure the test would fail if it checked the wiki repo
|
||||
FileUtils.rm_rf(project.wiki.repository.path_to_repo)
|
||||
|
||||
subject.perform(project.id)
|
||||
|
||||
expect(project.reload.last_repository_check_failed).to eq(false)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue