sb: Add git clean to the supported git commands.

This commit is contained in:
Chris Johns 2020-05-08 14:28:04 +10:00
parent da17bda77a
commit 1f972c2108
2 changed files with 17 additions and 0 deletions

View File

@ -515,6 +515,15 @@ def _git_downloader(url, local, config, opts):
log.notice('git: reset: %s' % (us[0]))
if _do_download(opts):
repo.reset(arg)
repo.submodule_foreach(['reset'] + arg)
elif _as[0] == 'clean':
arg = []
if len(_as) > 1:
arg = ['--%s' % (_as[1])]
log.notice('git: clean: %s' % (us[0]))
if _do_download(opts):
repo.clean(arg)
repo.submodule_foreach(['clean'] + arg)
elif _as[0] == 'protocol':
pass
else:

View File

@ -105,6 +105,14 @@ class repo:
def submodule(self, module):
ec, output = self._run(['submodule', 'update', '--init', module], check = True)
def submodule_foreach(self, args = []):
if type(args) == str:
args = [args.split(args)]
ec, output = self._run(['submodule',
'foreach',
'--recursive',
self.git] + args, check = True)
def submodules(self):
smodules = {}
ec, output = self._run(['submodule'], check = True)