sb: Update git support.

This commit is contained in:
Chris Johns 2014-08-09 23:51:02 +10:00
parent 4934771892
commit c21f09e060

View File

@ -97,7 +97,7 @@ class repo:
def submodule(self, module):
ec, output = self._run(['submodule', 'update', '--init', module], check = True)
def clean(self, args):
def clean(self, args = []):
if type(args) == str:
args = [args]
ec, output = self._run(['clean'] + args, check = True)
@ -109,29 +109,33 @@ class repo:
if ec == 0:
state = 'none'
for l in output.split('\n'):
if l.startswith('# On branch '):
_status['branch'] = l[len('# On branch '):]
elif l.startswith('# Changes to be committed:'):
if l.startswith('# '):
l = l[2:]
if l.startswith('On branch '):
_status['branch'] = l[len('On branch '):]
elif l.startswith('Changes to be committed:'):
state = 'staged'
elif l.startswith('# Changes not staged for commit:'):
elif l.startswith('Changes not staged for commit:'):
state = 'unstaged'
elif l.startswith('# Untracked files:'):
elif l.startswith('Untracked files:'):
state = 'untracked'
elif l.startswith('# HEAD detached'):
elif l.startswith('HEAD detached'):
state = 'detached'
elif state != 'none' and l[0] == '#':
if l.strip() != '#' and not l.startswith('# ('):
if state not in _status:
_status[state] = []
l = l[1:]
if ':' in l:
l = l.split(':')[1]
_status[state] += [l.strip()]
elif state != 'none' and len(l.strip()) != 0:
if l[0].isspace():
l = l.strip()
if l[0] != '(':
if state not in _status:
_status[state] = []
l = l[1:]
if ':' in l:
l = l.split(':')[1]
_status[state] += [l.strip()]
return _status
def dirty(self):
_status = self.status()
return len(_status) == 1 and 'branch' in _status
return not (len(_status) == 1 and 'branch' in _status)
def valid(self):
if path.exists(self.path):