diff --git a/src/hooks.py b/src/hooks.py index 5acf075..5130fa2 100644 --- a/src/hooks.py +++ b/src/hooks.py @@ -1,5 +1,3 @@ -"""Git hook integration for prepare-commit-msg.""" - import os import shutil from dataclasses import dataclass @@ -87,6 +85,19 @@ exec commit-gen hook "$@" try: hook_path = self.get_hook_path() + if not self.repo_path.exists(): + return HookResult( + success=False, + message=f"Repository path does not exist: {self.repo_path}" + ) + + git_dir = self.repo_path / ".git" + if not git_dir.exists(): + return HookResult( + success=False, + message=f"Git directory not found: {git_dir}. Are you in a git repository?" + ) + if not self.hooks_dir.exists(): return HookResult( success=False,