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:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-03-14 18:49:24 +0300
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-03-14 18:49:24 +0300
commit021d53c96d308df7c721984435442993357a3414 (patch)
tree13bd15cb10952efd5c759a5dee5b8de6f243e056 /app
parenta02fe251df7ea7316f51850fe603e7e5ac4431e2 (diff)
Run 'git gc' every 10 pushes
Diffstat (limited to 'app')
-rw-r--r--app/services/git_push_service.rb8
-rw-r--r--app/services/projects/housekeeping_service.rb16
2 files changed, 22 insertions, 2 deletions
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index bd31a617747..e50cbdfb602 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -49,6 +49,8 @@ class GitPushService < BaseService
# Update merge requests that may be affected by this push. A new branch
# could cause the last commit of a merge request to change.
update_merge_requests
+
+ perform_housekeeping
end
def update_main_language
@@ -73,6 +75,12 @@ class GitPushService < BaseService
ProjectCacheWorker.perform_async(@project.id)
end
+ def perform_housekeeping
+ housekeeping = Projects::HousekeepingService.new(@project)
+ housekeeping.increment!
+ housekeeping.execute if housekeeping.needed?
+ end
+
def process_default_branch
@push_commits = project.repository.commits(params[:newrev])
diff --git a/app/services/projects/housekeeping_service.rb b/app/services/projects/housekeeping_service.rb
index 11be5b1badf..83bdedf7a8d 100644
--- a/app/services/projects/housekeeping_service.rb
+++ b/app/services/projects/housekeeping_service.rb
@@ -19,9 +19,21 @@ module Projects
if !try_obtain_lease
return "Housekeeping was already triggered in the past #{LEASE_TIMEOUT / 60} minutes"
end
-
+
GitlabShellWorker.perform_async(:gc, @project.path_with_namespace)
- return "Housekeeping successfully started"
+ @project.pushes_since_gc = 0
+ @project.save!
+
+ "Housekeeping successfully started"
+ end
+
+ def needed?
+ @project.pushes_since_gc >= 10
+ end
+
+ def increment!
+ @project.pushes_since_gc += 1
+ @project.save!
end
private