From b4ec9263a9a7ddc88b658ce10a2626c2222b86da Mon Sep 17 00:00:00 2001 From: Marcus Rosenow Date: Mon, 10 Aug 2015 23:00:02 -0500 Subject: [PATCH] Refactor to use settings module --- bin/commands/state.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/commands/state.py b/bin/commands/state.py index 3d60d6c..cb76104 100644 --- a/bin/commands/state.py +++ b/bin/commands/state.py @@ -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 @@ -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: @@ -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()):