compare_versions
Compare two GitLab commits, branches, or tags to identify differences between versions for code review and change analysis.
Instructions
Compare two commits/branches/tags to see the differences between them.
Args:
project_id: The GitLab project ID or URL-encoded path
from_sha: The source commit/branch/tag
to_sha: The target commit/branch/tag
Returns:
Dict containing the comparison information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| from_sha | Yes | ||
| to_sha | Yes |
Implementation Reference
- server.py:323-343 (handler)The handler function for the 'compare_versions' tool. It is registered via the @mcp.tool() decorator. Fetches the GitLab project and uses repository_compare to get differences between two SHAs.def compare_versions(ctx: Context, project_id: str, from_sha: str, to_sha: str) -> Dict[str, Any]: """ Compare two commits/branches/tags to see the differences between them. Args: project_id: The GitLab project ID or URL-encoded path from_sha: The source commit/branch/tag to_sha: The target commit/branch/tag Returns: Dict containing the comparison information """ gl = ctx.request_context.lifespan_context project = gl.projects.get(project_id) try: result = project.repository_compare(from_sha, to_sha) except Exception as e: logger.error(f"Failed to compare {from_sha} and {to_sha}: {e}") result = {} return result