Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-05-04 17:10:49 +0300
committerDouwe Maan <douwe@gitlab.com>2016-05-04 17:10:49 +0300
commit466f6874af6d05f58bad35a81c08a9a199e98d52 (patch)
tree908d131360397414aa2297c17212ede0ed55229f /app
parent275c615557595996f704c9f45b16f435fc70b8e2 (diff)
parent9f85b7bc58485831a61da0f9acc530511ea7474a (diff)
Merge branch 'create-wikis-during-check' into 'master'
Initialize wikis on legacy projects during check Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/4173 Helps https://gitlab.com/gitlab-org/gitlab-ce/issues/15423 See merge request !3931
Diffstat (limited to 'app')
-rw-r--r--app/workers/repository_check/single_repository_worker.rb34
1 files changed, 23 insertions, 11 deletions
diff --git a/app/workers/repository_check/single_repository_worker.rb b/app/workers/repository_check/single_repository_worker.rb
index a76729e3c74..f2d12ba5a7d 100644
--- a/app/workers/repository_check/single_repository_worker.rb
+++ b/app/workers/repository_check/single_repository_worker.rb
@@ -1,9 +1,9 @@
module RepositoryCheck
class SingleRepositoryWorker
include Sidekiq::Worker
-
+
sidekiq_options retry: false
-
+
def perform(project_id)
project = Project.find(project_id)
project.update_columns(
@@ -11,20 +11,32 @@ module RepositoryCheck
last_repository_check_at: Time.now,
)
end
-
+
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
- repositories.map { |repository| git_fsck(repository.path_to_repo) }.all?
+ if !git_fsck(project.repository)
+ false
+ elsif project.wiki_enabled?
+ # Historically some projects never had their wiki repos initialized;
+ # this happens on project creation now. Let's initialize an empty repo
+ # if it is not already there.
+ begin
+ project.create_wiki
+ rescue Rugged::RepositoryError
+ end
+
+ git_fsck(project.wiki.repository)
+ else
+ true
+ end
end
-
- def git_fsck(path)
+
+ def git_fsck(repository)
+ path = repository.path_to_repo
cmd = %W(nice git --git-dir=#{path} fsck)
output, status = Gitlab::Popen.popen(cmd)
-
+
if status.zero?
true
else