sb: Fix git to clean before updating.

This commit is contained in:
Chris Johns
2014-03-26 17:13:25 +11:00
parent b77019a91e
commit 8c19df26f6
3 changed files with 8 additions and 2 deletions

View File

@@ -211,6 +211,7 @@ def _git_downloader(url, local, config, opts):
if not opts.dry_run(): if not opts.dry_run():
repo.clone(us[0], local) repo.clone(us[0], local)
else: else:
repo.clean(['-f', '-d'])
repo.reset('--hard') repo.reset('--hard')
repo.checkout('master') repo.checkout('master')
for a in us[1:]: for a in us[1:]:

View File

@@ -97,6 +97,11 @@ class repo:
def submodule(self, module): def submodule(self, module):
ec, output = self._run(['submodule', 'update', '--init', module], check = True) ec, output = self._run(['submodule', 'update', '--init', module], check = True)
def clean(self, args):
if type(args) == str:
args = [args]
ec, output = self._run(['clean'] + args, check = True)
def status(self): def status(self):
_status = {} _status = {}
if path.exists(self.path): if path.exists(self.path):
@@ -124,7 +129,7 @@ class repo:
_status[state] += [l.strip()] _status[state] += [l.strip()]
return _status return _status
def clean(self): def dirty(self):
_status = self.status() _status = self.status()
return len(_status) == 1 and 'branch' in _status return len(_status) == 1 and 'branch' in _status

View File

@@ -302,7 +302,7 @@ class command_line:
if repo.valid(): if repo.valid():
repo_valid = '1' repo_valid = '1'
repo_head = repo.head() repo_head = repo.head()
repo_clean = repo.clean() repo_clean = not repo.dirty()
repo_id = repo_head repo_id = repo_head
if not repo_clean: if not repo_clean:
repo_id += '-modified' repo_id += '-modified'