From e0e3f3b81c16a8ce17697ea15c7cae2d55ca161e Mon Sep 17 00:00:00 2001
From: Tobias Henkel <tobias.henkel@bmw.de>
Date: Mon, 2 Mar 2020 09:54:56 +0100
Subject: [PATCH] Optimize repos for size when preparing for nodecache

We currently run 'git gc' on repos before creating the tarball for the
node cache. On busy repos this is not enough to cut down the size of
the repo. With more aggressive pruning and packing one of our repos in
the cache got down from 6GB to 1.8GB.

Change-Id: I7ef428c25fde713efabd966d59b5bd97ec248d7e
---
 roles/git-prepare-nodecache/tasks/main.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/roles/git-prepare-nodecache/tasks/main.yaml b/roles/git-prepare-nodecache/tasks/main.yaml
index 38d0aa7df..e3066f299 100644
--- a/roles/git-prepare-nodecache/tasks/main.yaml
+++ b/roles/git-prepare-nodecache/tasks/main.yaml
@@ -19,7 +19,7 @@
     - skip_ansible_lint
 
 - name: Run git garbage collection
-  command: git gc
+  command: git gc --prune=now --aggressive
   args:
     chdir: "{{ git_cache_root }}/{{ item.canonical_name }}"
   with_items: "{{ zuul.projects.values() | list }}"