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