Renames some RepoStats class qualifiers to more generic terms

untracked -> new
not_staged -> changed
This commit is contained in:
Emanuel Angelo 2017-09-14 00:25:24 +01:00
parent 82e85bf14c
commit 2c0a5909ce
4 changed files with 19 additions and 19 deletions

View file

@ -24,16 +24,16 @@ def _get_bzr_branch():
def parse_bzr_stats(status):
stats = RepoStats()
statustype = "not_staged"
statustype = "changed"
for statusline in status:
if statusline[:2] == " ":
setattr(stats, statustype, getattr(stats, statustype) + 1)
elif statusline == "added:":
statustype = "staged"
elif statusline == "unknown:":
statustype = "untracked"
statustype = "new"
else: # removed, missing, renamed, modified or kind changed
statustype = "not_staged"
statustype = "changed"
return stats

View file

@ -47,12 +47,12 @@ def parse_git_stats(status):
for statusline in status[1:]:
code = statusline[:2]
if code == '??':
stats.untracked += 1
stats.new += 1
elif code in ('DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU'):
stats.conflicted += 1
else:
if code[1] != ' ':
stats.not_staged += 1
stats.changed += 1
if code[0] != ' ':
stats.staged += 1

View file

@ -20,10 +20,10 @@ class Segment(BasicSegment):
stats = RepoStats()
for line in stdout.splitlines():
if line[0] == "?":
stats.untracked += 1
stats.new += 1
elif line[0] == "C":
stats.conflicted += 1
elif line[0] in ["A", "D", "I", "M", "R", "!", "~"]:
stats.not_staged += 1
stats.changed += 1
stats.add_to_powerline(self.powerline)

View file

@ -14,24 +14,24 @@ class RepoStats(object):
'ahead': u'\u2B06',
'behind': u'\u2B07',
'staged': u'\u2714',
'not_staged': u'\u270E',
'untracked': u'\u2753',
'changed': u'\u270E',
'new': u'\u2753',
'conflicted': u'\u273C'
}
def __init__(self):
self.ahead = 0
self.behind = 0
self.untracked = 0
self.not_staged = 0
self.new = 0
self.changed = 0
self.staged = 0
self.conflicted = 0
@property
def dirty(self):
qualifiers = [
self.untracked,
self.not_staged,
self.new,
self.changed,
self.staged,
self.conflicted,
]
@ -45,11 +45,11 @@ class RepoStats(object):
the value of the property as a string when the value is greater than
1. When it is not greater than one, returns an empty string.
As an example, if you want to show an icon for untracked files, but you
only want a number to appear next to the icon when there are more than
one untracked files, you can do:
As an example, if you want to show an icon for new files, but you only
want a number to appear next to the icon when there are more than one
new file, you can do:
segment = repo_stats.n_or_empty("untracked") + icon_string
segment = repo_stats.n_or_empty("new") + icon_string
"""
return unicode(self[_key]) if int(self[_key]) > 1 else u''
@ -62,8 +62,8 @@ class RepoStats(object):
add('ahead', color.GIT_AHEAD_FG, color.GIT_AHEAD_BG)
add('behind', color.GIT_BEHIND_FG, color.GIT_BEHIND_BG)
add('staged', color.GIT_STAGED_FG, color.GIT_STAGED_BG)
add('not_staged', color.GIT_NOTSTAGED_FG, color.GIT_NOTSTAGED_BG)
add('untracked', color.GIT_UNTRACKED_FG, color.GIT_UNTRACKED_BG)
add('changed', color.GIT_NOTSTAGED_FG, color.GIT_NOTSTAGED_BG)
add('new', color.GIT_UNTRACKED_FG, color.GIT_UNTRACKED_BG)
add('conflicted', color.GIT_CONFLICTED_FG, color.GIT_CONFLICTED_BG)