validate_commit_readiness
Assess repository readiness for commit by validating checks, identifying issues, and providing actionable recommendations to ensure compliance before code submission.
Instructions
Comprehensive validation of repository readiness for commit.
Args: repo_path: Path to git repository
Returns: Dict containing: - ready_to_commit: Boolean overall readiness - checks: Dict of individual validation checks - recommendations: List of actions to take before commit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes |
Implementation Reference
- MCP tool handler implementing the validate_commit_readiness functionality. Performs repository status checks, determines readiness for commit, generates recommendations, and returns structured response.@mcp.tool() @handle_errors(log_errors=True) def validate_commit_readiness(repo_path: str) -> Dict[str, Any]: """ Comprehensive validation of repository readiness for commit. Args: repo_path: Path to git repository Returns: Dict containing: - ready_to_commit: Boolean overall readiness - checks: Dict of individual validation checks - recommendations: List of actions to take before commit """ # Initialize service for the specified repository try: target_service = CommitzenService(repo_path=repo_path) except Exception as e: raise RepositoryError( f"Failed to initialize service for repository '{repo_path}'", repo_path=repo_path, cause=e, ) if not target_service.git_enabled: raise RepositoryError( "Git operations not available - not in a git repository", repo_path=repo_path, ) # Get repository status status = target_service.get_repository_status() if "error" in status: raise GitOperationError(status["error"], repo_path=repo_path) # Perform readiness checks checks = { "is_git_repository": status.get("is_git_repository", False), "has_staged_files": not status.get("staging_clean", True), "staged_files_count": status.get("staged_files_count", 0), } # Determine overall readiness ready_to_commit = ( checks["is_git_repository"] and checks["has_staged_files"] and checks["staged_files_count"] > 0 ) # Generate recommendations recommendations = [] if not checks["is_git_repository"]: recommendations.append("Initialize git repository") if not checks["has_staged_files"]: recommendations.append("Stage files for commit using 'git add'") if checks["staged_files_count"] == 0: recommendations.append("Add files to staging area before committing") if ready_to_commit: recommendations.append("Repository is ready for commit") return create_success_response( { "ready_to_commit": ready_to_commit, "git_enabled": True, "checks": checks, "recommendations": recommendations, "repository_status": status, "repository_path": repo_path, } )
- src/commit_helper_mcp/mcp_server.py:33-43 (registration)Registration of the validate_commit_readiness tool by importing it from git_tools module into the main MCP server module, making it available as part of the server tools.# Git tools from .server.git_tools import ( get_git_implementation_info, get_enhanced_git_status, get_git_status, preview_git_commit, execute_git_commit, generate_and_commit, validate_commit_readiness, stage_files_and_commit, )