get_commit
Retrieve detailed commit information from Bitbucket repositories, including message, author, date, and parent commits, by providing repository slug and commit hash.
Instructions
Get detailed information about a specific commit.
Args:
repo_slug: Repository slug
commit: Commit hash (full or short)
Returns:
Commit details including message, author, date, and parents
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_slug | Yes | ||
| commit | Yes |
Implementation Reference
- src/server.py:775-794 (handler)MCP tool handler for 'get_commit'. Fetches commit details via BitbucketClient and formats using CommitDetail model.@mcp.tool() @handle_bitbucket_error @formatted def get_commit(repo_slug: str, commit: str) -> dict: """Get detailed information about a specific commit. Args: repo_slug: Repository slug commit: Commit hash (full or short) Returns: Commit details including message, author, date, and parents """ client = get_client() result = client.get_commit(repo_slug, commit) if not result: return not_found_response("Commit", commit) return CommitDetail.from_api(result).model_dump()
- src/models.py:190-227 (schema)Pydantic schema/model for formatting commit details returned by the get_commit tool.class CommitDetail(BaseModel): """Commit info for get responses.""" hash: str message: str = "" author_raw: Optional[str] = None author_user: Optional[str] = None date: Optional[str] = None parents: list[str] = [] @field_validator("date", mode="before") @classmethod def truncate_ts(cls, v: Any) -> Optional[str]: return truncate_timestamp(v) @classmethod def from_api(cls, data: dict) -> "CommitDetail": author = data.get("author") or {} return cls( hash=data.get("hash", ""), message=data.get("message", ""), author_raw=author.get("raw"), author_user=(author.get("user") or {}).get("display_name"), date=data.get("date"), parents=[(p.get("hash") or "")[:12] for p in data.get("parents", [])], ) # ==================== BRANCHES ==================== class BranchSummary(BaseModel): """Branch info for list responses.""" name: str commit: str message: str = "" date: Optional[str] = None
- src/bitbucket_client.py:850-862 (helper)BitbucketClient helper method that performs the actual API request to retrieve commit information.def get_commit( self, repo_slug: str, commit: str ) -> Optional[dict[str, Any]]: """Get commit details. Args: repo_slug: Repository slug commit: Commit hash (full or short) Returns: Commit info or None if not found """ return self._request("GET", self._repo_path(repo_slug, "commit", commit))