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_MODIFIED
|
||||||
| git.GIT_STATUS_INDEX_DELETED):
|
| git.GIT_STATUS_INDEX_DELETED):
|
||||||
index_column = 'I'
|
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):
|
def branch(self):
|
||||||
try:
|
try:
|
||||||
|
@ -132,7 +133,7 @@ except ImportError:
|
||||||
wt_column = 'D'
|
wt_column = 'D'
|
||||||
|
|
||||||
r = wt_column + index_column + untracked_column
|
r = wt_column + index_column + untracked_column
|
||||||
return r
|
return r if r != ' ' else None
|
||||||
|
|
||||||
def branch(self):
|
def branch(self):
|
||||||
for line in self._gitcmd('branch', '-l'):
|
for line in self._gitcmd('branch', '-l'):
|
||||||
|
|
|
@ -55,7 +55,7 @@ def branch(status_colors=True):
|
||||||
if status_colors:
|
if status_colors:
|
||||||
return [{
|
return [{
|
||||||
'contents': branch,
|
'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:
|
else:
|
||||||
return branch
|
return branch
|
||||||
|
|
|
@ -327,7 +327,7 @@ def branch(segment_info, status_colors=True):
|
||||||
if repo:
|
if repo:
|
||||||
return [{
|
return [{
|
||||||
'contents': repo.branch(),
|
'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',
|
'divider_highlight_group': 'branch:divider',
|
||||||
}]
|
}]
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TestVCS(TestCase):
|
||||||
repo = guess(path=GIT_REPO)
|
repo = guess(path=GIT_REPO)
|
||||||
self.assertNotEqual(repo, None)
|
self.assertNotEqual(repo, None)
|
||||||
self.assertEqual(repo.branch(), 'master')
|
self.assertEqual(repo.branch(), 'master')
|
||||||
self.assertEqual(repo.status(), ' ')
|
self.assertEqual(repo.status(), None)
|
||||||
self.assertEqual(repo.status('file'), None)
|
self.assertEqual(repo.status('file'), None)
|
||||||
with open(os.path.join(GIT_REPO, 'file'), 'w') as f:
|
with open(os.path.join(GIT_REPO, 'file'), 'w') as f:
|
||||||
f.write('abc')
|
f.write('abc')
|
||||||
|
@ -65,6 +65,7 @@ class TestVCS(TestCase):
|
||||||
repo = guess(path=HG_REPO)
|
repo = guess(path=HG_REPO)
|
||||||
self.assertNotEqual(repo, None)
|
self.assertNotEqual(repo, None)
|
||||||
self.assertEqual(repo.branch(), 'default')
|
self.assertEqual(repo.branch(), 'default')
|
||||||
|
self.assertEqual(repo.status(), None)
|
||||||
with open(os.path.join(HG_REPO, 'file'), 'w') as f:
|
with open(os.path.join(HG_REPO, 'file'), 'w') as f:
|
||||||
f.write('abc')
|
f.write('abc')
|
||||||
f.flush()
|
f.flush()
|
||||||
|
|
|
@ -46,7 +46,7 @@ class TestCommon(TestCase):
|
||||||
self.assertEqual(common.user(), [{'contents': 'def', 'highlight_group': ['superuser', 'user']}])
|
self.assertEqual(common.user(), [{'contents': 'def', 'highlight_group': ['superuser', 'user']}])
|
||||||
|
|
||||||
def test_branch(self):
|
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=False), 'tests')
|
||||||
self.assertEqual(common.branch(status_colors=True),
|
self.assertEqual(common.branch(status_colors=True),
|
||||||
[{'contents': 'tests', 'highlight_group': ['branch_clean', 'branch']}])
|
[{'contents': 'tests', 'highlight_group': ['branch_clean', 'branch']}])
|
||||||
|
|
Loading…
Reference in New Issue