Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/tools/what-changed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { run, getBranch, getDiffStat } from "../lib/git.js";
import { run, getBranch, getDiffFiles, getDiffStat } from "../lib/git.js";

export function registerWhatChanged(server: McpServer): void {
server.tool(
Expand All @@ -12,8 +12,9 @@ export function registerWhatChanged(server: McpServer): void {
async ({ since }) => {
const ref = since || "HEAD~5";
const diffStat = getDiffStat(ref);
const diffFiles = run(`git diff ${ref} --name-only 2>/dev/null || git diff HEAD~3 --name-only`);
const log = run(`git log ${ref}..HEAD --oneline 2>/dev/null || git log -5 --oneline`);
const diffFiles = getDiffFiles(ref);
const logResult = run(["log", `${ref}..HEAD`, "--oneline"]);
const log = logResult.startsWith("[") ? run(["log", "-5", "--oneline"]) : logResult;
const branch = getBranch();

const fileList = diffFiles.split("\n").filter(Boolean);
Expand Down
Loading