Skip to main content
Glama

get_git_log_by_repo

Retrieve git commit history from a specified repository to automatically populate CV/resume project sections with recent coding activity and contributions.

Instructions

Get git commits from a specific repository by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_nameYesName of the repository (e.g., 'CompanyA', 'Personal')
sinceNoTime range for commits6 months ago

Implementation Reference

  • The primary handler function that executes the tool logic: runs 'git log' for the specified repository, filters by author (AUTHOR_NAME env var), excludes merge commits, limits by 'since' time string, and returns formatted commit list or errors.
    async def get_git_log_by_repo(repo_name: Optional[str], since: str) -> list[TextContent]:
        """Get git commits from a specific repository."""
        if not repo_name:
            return [TextContent(type="text", text="Error: repo_name is required")]
        
        if not REPO_DICT:
            return [TextContent(type="text", text="No repositories configured")]
        
        if repo_name not in REPO_DICT:
            available = ", ".join(REPO_DICT.keys())
            return [TextContent(
                type="text",
                text=f"Repository '{repo_name}' not found.\n\nAvailable repositories: {available}"
            )]
        
        repo_path = REPO_DICT[repo_name]
        
        try:
            cmd = [
                "git", "log",
                f"--author={AUTHOR_NAME}",
                "--no-merges",
                f"--since={since}",
                "--pretty=format:%h - %s (%cr)"
            ]
            
            result = subprocess.run(
                cmd,
                cwd=repo_path,
                capture_output=True,
                text=True,
                check=True
            )
            
            output = result.stdout.strip()
            return [TextContent(
                type="text",
                text=f"Git commits from '{repo_name}' ({repo_path}):\n\n{output if output else 'No commits found'}"
            )]
        
        except subprocess.CalledProcessError as e:
            return [TextContent(type="text", text=f"Git error for '{repo_name}': {e.stderr}")]
  • Defines the tool's input schema, including required 'repo_name' parameter and optional 'since' with default, along with description.
    Tool(
        name="get_git_log_by_repo",
        description="Get git commits from a specific repository by name",
        inputSchema={
            "type": "object",
            "properties": {
                "repo_name": {
                    "type": "string",
                    "description": "Name of the repository (e.g., 'CompanyA', 'Personal')"
                },
                "since": {
                    "type": "string",
                    "description": "Time range for commits",
                    "default": "6 months ago"
                }
            },
            "required": ["repo_name"]
        }
    ),
  • Registers the tool handler by dispatching calls to 'get_git_log_by_repo' function in the main @app.call_tool() method.
    elif name == "get_git_log_by_repo":
        return await get_git_log_by_repo(
            arguments.get("repo_name"),
            arguments.get("since", "6 months ago")
        )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/eyaab/cv-resume-builder-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server