Merge remote-tracking branch 'zyx-i/326-fix-None-handling' into develop
This commit is contained in:
commit
8cdd12a800
|
@ -73,7 +73,8 @@ try:
|
|||
| git.GIT_STATUS_INDEX_MODIFIED
|
||||
| git.GIT_STATUS_INDEX_DELETED):
|
||||
index_column = 'I'
|
||||
return wt_column + index_column + untracked_column
|
||||
r = wt_column + index_column + untracked_column
|
||||
return r if r != ' ' else None
|
||||
|
||||
def branch(self):
|
||||
try:
|
||||
|
@ -132,7 +133,7 @@ except ImportError:
|
|||
wt_column = 'D'
|
||||
|
||||
r = wt_column + index_column + untracked_column
|
||||
return r
|
||||
return r if r != ' ' else None
|
||||
|
||||
def branch(self):
|
||||
for line in self._gitcmd('branch', '-l'):
|
||||
|
|
|
@ -55,7 +55,7 @@ def branch(status_colors=True):
|
|||
if status_colors:
|
||||
return [{
|
||||
'contents': branch,
|
||||
'highlight_group': ['branch_dirty' if repo.status().strip() else 'branch_clean', 'branch'],
|
||||
'highlight_group': ['branch_dirty' if repo.status() else 'branch_clean', 'branch'],
|
||||
}]
|
||||
else:
|
||||
return branch
|
||||
|
|
|
@ -327,7 +327,7 @@ def branch(segment_info, status_colors=True):
|
|||
if repo:
|
||||
return [{
|
||||
'contents': repo.branch(),
|
||||
'highlight_group': (['branch_dirty' if repo.status().strip() else 'branch_clean'] if status_colors else []) + ['branch'],
|
||||
'highlight_group': (['branch_dirty' if repo.status() else 'branch_clean'] if status_colors else []) + ['branch'],
|
||||
'divider_highlight_group': 'branch:divider',
|
||||
}]
|
||||
return None
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestVCS(TestCase):
|
|||
repo = guess(path=GIT_REPO)
|
||||
self.assertNotEqual(repo, None)
|
||||
self.assertEqual(repo.branch(), 'master')
|
||||
self.assertEqual(repo.status(), ' ')
|
||||
self.assertEqual(repo.status(), None)
|
||||
self.assertEqual(repo.status('file'), None)
|
||||
with open(os.path.join(GIT_REPO, 'file'), 'w') as f:
|
||||
f.write('abc')
|
||||
|
@ -65,6 +65,7 @@ class TestVCS(TestCase):
|
|||
repo = guess(path=HG_REPO)
|
||||
self.assertNotEqual(repo, None)
|
||||
self.assertEqual(repo.branch(), 'default')
|
||||
self.assertEqual(repo.status(), None)
|
||||
with open(os.path.join(HG_REPO, 'file'), 'w') as f:
|
||||
f.write('abc')
|
||||
f.flush()
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestCommon(TestCase):
|
|||
self.assertEqual(common.user(), [{'contents': 'def', 'highlight_group': ['superuser', 'user']}])
|
||||
|
||||
def test_branch(self):
|
||||
with replace_module_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: ' ')):
|
||||
with replace_module_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: None)):
|
||||
self.assertEqual(common.branch(status_colors=False), 'tests')
|
||||
self.assertEqual(common.branch(status_colors=True),
|
||||
[{'contents': 'tests', 'highlight_group': ['branch_clean', 'branch']}])
|
||||
|
|
Loading…
Reference in New Issue