gc: introduce -c|--cloud

Fixes #876

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-07-11 22:27:13 +03:00
parent d71df35f63
commit d63d1db5b6
3 changed files with 15 additions and 2 deletions
+8
View File
@@ -314,6 +314,14 @@ def parse_args(argv=None):
action='store_true',
default=False,
help='Collect garbage for all branches.')
gc_parser.add_argument('-c',
'--cloud',
action='store_true',
default=False,
help='Collect garbage in remote repository')
gc_parser.add_argument('-r',
'--remote',
help='Remote repository to collect garbage in')
gc_parser.set_defaults(func=CmdGC)
# Config
+3 -1
View File
@@ -3,5 +3,7 @@ from dvc.command.common.base import CmdBase
class CmdGC(CmdBase):
def run(self):
self.project.gc()
self.project.gc(all_branches=self.args.all_branches,
cloud=self.args.cloud,
remote=self.args.remote)
return 0
+4 -1
View File
@@ -291,7 +291,7 @@ class Project(object):
return cache
def gc(self, all_branches=False):
def gc(self, all_branches=False, cloud=False, remote=None):
clist = self._used_cache(target=None, all_branches=all_branches)
self.cache.local.gc(clist)
@@ -310,6 +310,9 @@ class Project(object):
if self.cache.azure:
self.cache.azure.gc(clist)
if cloud:
self.cloud._get_cloud(remote).gc(clist)
def push(self, target=None, jobs=1, remote=None, all_branches=False):
self.cloud.push(self._used_cache(target, all_branches)['local'], jobs, remote=remote)