From a508139e3fa259392e26f804c54bd71ba109c819 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 15 Mar 2022 20:30:36 +0300 Subject: get rid of annoying "false" messages in output --- cgitize/cgit.py | 3 ++- cgitize/git.py | 2 +- cgitize/utils.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cgitize/cgit.py b/cgitize/cgit.py index 769690b..dd06216 100644 --- a/cgitize/cgit.py +++ b/cgitize/cgit.py @@ -115,7 +115,8 @@ class CGitRepositories: return self._mirror(repo) with chdir(repo_dir): - if not Git.check('rev-parse', '--is-inside-work-tree'): + success, output = Git.capture('rev-parse', '--is-inside-work-tree') + if not success: # Overwrite the existing directory if it's not a Git repository. logging.warning('Local directory is not a repository, going to overwrite it: %s', repo_dir) return self._mirror(repo) diff --git a/cgitize/git.py b/cgitize/git.py index 14ccce7..35b2e1e 100644 --- a/cgitize/git.py +++ b/cgitize/git.py @@ -145,7 +145,7 @@ class Git: @staticmethod def capture(*args, **kwargs): - return utils.try_run_capture(Git.EXE, *args, env=GIT_ENV, **kwargs) + return utils.try_capture(Git.EXE, *args, env=GIT_ENV, **kwargs) @staticmethod def get_global_config(): diff --git a/cgitize/utils.py b/cgitize/utils.py index 64b419a..78834c9 100644 --- a/cgitize/utils.py +++ b/cgitize/utils.py @@ -53,11 +53,11 @@ def try_run(*args, **kwargs): return e.returncode == 0 -def run_capture(*args, **kwargs): +def capture(*args, **kwargs): return run(*args, capture_output=True, **kwargs) -def try_run_capture(*args, **kwargs): +def try_capture(*args, **kwargs): try: return True, run(*args, capture_output=True, **kwargs) except subprocess.CalledProcessError as e: -- cgit v1.2.3