Skip to content

Commit

Permalink
Refactor to use settings module
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Rosenow authored and Marcus Rosenow committed Aug 11, 2015
1 parent 8fc43ba commit b4ec926
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bin/commands/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ast import literal_eval
from subprocess import call, check_output, PIPE, Popen

from commands import settings
from utils.messages import error


Expand Down Expand Up @@ -44,7 +45,7 @@ def _only_default_branch():
if len(branches) > 1:
return False

default_branch = check_output('git settings get -d master git-state.branches.default'.split()).splitlines()[0]
default_branch = settings.get('git-state.branches.default', default='master')
if re.match('\* {}'.format(default_branch), branches[0]) is not None:
return True
else:
Expand All @@ -63,8 +64,11 @@ def _is_new_repository():
def state(show_color, format, show_status, log_count, reflog_count, show_branches, show_stashes, show_empty, clear):
"""Print the state of the working tree."""

settings_command = ['git', 'settings', 'get', '-d', 'True', 'git-state.branches.show-only-default']
show_only_default_branch = literal_eval(check_output(settings_command))
show_only_default_branch = settings.get(
'git-state.branches.show-only-default',
default=True,
as_type=settings.as_bool
)

show_color = show_color.lower()
if show_color == 'never' or (show_color == 'auto' and not sys.stdout.isatty()):
Expand Down

0 comments on commit b4ec926

Please sign in to comment.