diff --git a/cfbs/commands.py b/cfbs/commands.py index 1d90860..140e2b6 100644 --- a/cfbs/commands.py +++ b/cfbs/commands.py @@ -53,7 +53,7 @@ ) from cfbs.index import _VERSION_INDEX, Index from cfbs.git import ( - check_git_exists, + git_exists, is_git_repo, git_commit, git_get_config, @@ -179,9 +179,7 @@ def init_command(index=None, masterfiles=None, non_interactive=False) -> int: do_git = True if do_git == "yes" else False if do_git is True: - try: - check_git_exists() - except FileNotFoundError as e: + if not git_exists(): print("Command 'git' was not found") return 1 diff --git a/cfbs/git.py b/cfbs/git.py index 7be7cbd..f8a71d8 100644 --- a/cfbs/git.py +++ b/cfbs/git.py @@ -18,11 +18,12 @@ class CFBSGitError(Exception): pass -def check_git_exists(): +def git_exists(): try: check_call(["git", "--version"], stdout=DEVNULL) - except CalledProcessError as cpe: - raise CFBSGitError("'git' was not found") from cpe + return True + except FileNotFoundError: + return False def ls_remote(remote, branch):