diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-11-03 06:17:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-11-03 06:17:33 +0000 |
commit | 22b6d3abcec9046e294d08c741aa7b6338984e84 (patch) | |
tree | a0a9c823a7d82771ffb8a8b39f7143d5ba2f6b30 /pre_commit/main.py | |
parent | Adding upstream version 2.7.1. (diff) | |
download | pre-commit-22b6d3abcec9046e294d08c741aa7b6338984e84.tar.xz pre-commit-22b6d3abcec9046e294d08c741aa7b6338984e84.zip |
Adding upstream version 2.8.2.upstream/2.8.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/main.py')
-rw-r--r-- | pre_commit/main.py | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/pre_commit/main.py b/pre_commit/main.py index 8647960..c1eb104 100644 --- a/pre_commit/main.py +++ b/pre_commit/main.py @@ -23,10 +23,8 @@ from pre_commit.commands.run import run from pre_commit.commands.sample_config import sample_config from pre_commit.commands.try_repo import try_repo from pre_commit.error_handler import error_handler -from pre_commit.error_handler import FatalError from pre_commit.logging_handler import logging_handler from pre_commit.store import Store -from pre_commit.util import CalledProcessError logger = logging.getLogger('pre_commit') @@ -146,21 +144,8 @@ def _adjust_args_and_chdir(args: argparse.Namespace) -> None: if args.command == 'try-repo' and os.path.exists(args.repo): args.repo = os.path.abspath(args.repo) - try: - toplevel = git.get_root() - except CalledProcessError: - raise FatalError( - 'git failed. Is it installed, and are you in a Git repository ' - 'directory?', - ) - else: - if toplevel == '': # pragma: no cover (old git) - raise FatalError( - 'git toplevel unexpectedly empty! make sure you are not ' - 'inside the `.git` directory of your repository.', - ) - else: - os.chdir(toplevel) + toplevel = git.get_root() + os.chdir(toplevel) args.config = os.path.relpath(args.config) if args.command in {'run', 'try-repo'}: @@ -339,11 +324,11 @@ def main(argv: Optional[Sequence[str]] = None) -> int: parser.parse_args(['--help']) with error_handler(), logging_handler(args.color): + git.check_for_cygwin_mismatch() + if args.command not in COMMANDS_NO_GIT: _adjust_args_and_chdir(args) - git.check_for_cygwin_mismatch() - store = Store() store.mark_config_used(args.config) |