@@ -2497,11 +2497,44 @@ def main() -> int:
24972497 # Show version info and exit if requested
24982498 if args .version :
24992499 display_version ()
2500+ return 0
25002501
25012502 # Configure logging level
25022503 if args .verbose :
25032504 logger .setLevel (logging .DEBUG )
25042505
2506+ # Early git status check to avoid unnecessary Ollama loading
2507+ try :
2508+ print (f"\n { Colors .BLUE } 🔍 Checking for changes in repository...{ Colors .RESET } " )
2509+ # Simple check if git is installed and repository exists
2510+ result = subprocess .run (
2511+ ["git" , "status" , "--porcelain" ],
2512+ cwd = args .repo_path ,
2513+ capture_output = True ,
2514+ text = True ,
2515+ encoding = 'utf-8' ,
2516+ errors = 'replace'
2517+ )
2518+
2519+ if result .returncode != 0 :
2520+ print (f"\n { Colors .RED } ❌ Error: Not a git repository or git command failed.{ Colors .RESET } " )
2521+ print (f"Please ensure you're in a git repository and git is installed." )
2522+ return 1
2523+
2524+ # Check if there are any changes to commit
2525+ if not result .stdout .strip ():
2526+ print (f"\n { Colors .GREEN } ✅ No changes to commit. Working directory is clean.{ Colors .RESET } " )
2527+ return 0
2528+
2529+ # Proceed only if there are changes
2530+ change_count = len ([line for line in result .stdout .splitlines () if line .strip ()])
2531+ print (f"{ Colors .GREEN } ✅ Found { change_count } changed files in repository.{ Colors .RESET } " )
2532+ logger .debug (f"Changes detected in repository ({ change_count } files). Proceeding with analysis." )
2533+
2534+ except Exception as e :
2535+ print (f"\n { Colors .RED } ❌ Error checking git status: { str (e )} { Colors .RESET } " )
2536+ return 1
2537+
25052538 # Print welcome message
25062539 print (f"\n { '=' * 60 } " )
25072540 print (f"{ Colors .BOLD } { Colors .BLUE } 🚀 Smart Git Commit v{ get_version ()} { Colors .RESET } " )
@@ -2619,12 +2652,11 @@ def main() -> int:
26192652 print ("\n Solutions:" )
26202653 print (f" 1. { Colors .CYAN } Install pre-commit: pip install pre-commit{ Colors .RESET } " )
26212654 print (f" 2. { Colors .CYAN } Run with hooks skipped: smart-git-commit --skip-hooks{ Colors .RESET } " )
2622- return 1
26232655 else :
26242656 logger .error (f"Failed to execute commits: { str (e )} " )
26252657 print (f"\n { Colors .RED } ❌ ERROR during commit execution: { str (e )} { Colors .RESET } \n " )
2626- return 1
2627-
2658+ return 1
2659+
26282660 except KeyboardInterrupt :
26292661 print (f"\n \n { Colors .YELLOW } 🛑 Operation cancelled by user.{ Colors .RESET } " )
26302662 if workflow and not args .no_revert :
0 commit comments