aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-01-20 11:31:37 +0100
committerGuido Günther <agx@sigxcpu.org>2017-01-20 11:57:03 +0100
commit58473689b81d13300df2cd9aecf65fee97a4432e (patch)
tree5c1f0f9e8bf972b0b69e42d1f4e2e2884283b234
parentd3cb4db91a658037054312966771c3446cb2e4b5 (diff)
GitRepository: make garbage_collect more useful
-rw-r--r--gbp/git/repository.py13
-rw-r--r--tests/doctests/test_GitRepository.py4
2 files changed, 13 insertions, 4 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index a39fea1..25d2bca 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1794,15 +1794,22 @@ class GitRepository(object):
if ret:
raise GitRepositoryError("Unable to archive %s: %s" % (treeish, err.strip()))
- def collect_garbage(self, auto=False):
+ def collect_garbage(self, auto=False, prune=False, aggressive=False):
"""
Cleanup unnecessary files and optimize the local repository
param auto: only cleanup if required
param auto: C{bool}
"""
- args = ['--auto'] if auto else []
- self._git_command("gc", args)
+ args = GitArgs('--quiet')
+ if prune is True:
+ args.add('--prune')
+ else:
+ args.add_true(prune, '--prune=%s' % prune)
+ args.add_true(aggressive, '--aggressive')
+ args.add_true(auto, '--auto')
+ self._git_command("gc", args.args)
+
#{ Submodules
diff --git a/tests/doctests/test_GitRepository.py b/tests/doctests/test_GitRepository.py
index 348c560..cc3933a 100644
--- a/tests/doctests/test_GitRepository.py
+++ b/tests/doctests/test_GitRepository.py
@@ -823,7 +823,7 @@ def test_checkout():
def test_gc():
"""
- Test garbace collection
+ Test garbage collection
Methods tested:
- L{gbp.git.GitRepository.collect_garbage}
@@ -831,6 +831,8 @@ def test_gc():
>>> import gbp.git
>>> repo = gbp.git.GitRepository(dirs['repo'])
>>> repo.collect_garbage()
+ >>> repo.collect_garbage(prune=True)
+ >>> repo.collect_garbage(prune='all', aggressive=True)
"""