MCPcopy Create free account
hub / github.com/JordanCoin/codemap / handleGetDiff

Function handleGetDiff

mcp/main.go:313–355  ·  view source on GitHub ↗
(ctx context.Context, req *mcp.CallToolRequest, input DiffInput)

Source from the content-addressed store, hash-verified

311}
312
313func handleGetDiff(ctx context.Context, req *mcp.CallToolRequest, input DiffInput) (*mcp.CallToolResult, any, error) {
314 ref := input.Ref
315 if ref == "" {
316 ref = "main"
317 }
318
319 absRoot, err := filepath.Abs(input.Path)
320 if err != nil {
321 return errorResult("Invalid path: " + err.Error()), nil, nil
322 }
323
324 diffInfo, err := scanner.GitDiffInfo(absRoot, ref)
325 if err != nil {
326 return errorResult("Git diff error: " + err.Error() + "\nMake sure '" + ref + "' is a valid branch/ref"), nil, nil
327 }
328
329 if len(diffInfo.Changed) == 0 {
330 return textResult("No files changed vs " + ref), nil, nil
331 }
332
333 gitCache := scanner.NewGitIgnoreCache(input.Path)
334 files, err := scanner.ScanFiles(input.Path, gitCache, nil, nil)
335 if err != nil {
336 return errorResult("Scan error: " + err.Error()), nil, nil
337 }
338
339 files = scanner.FilterToChangedWithInfo(files, diffInfo)
340 impact := scanner.AnalyzeImpact(absRoot, files)
341
342 project := scanner.Project{
343 Root: absRoot,
344 Mode: "tree",
345 Files: files,
346 DiffRef: ref,
347 Impact: impact,
348 }
349
350 var buf bytes.Buffer
351 render.Tree(&buf, project)
352 output := stripANSI(buf.String())
353
354 return textResult(output), nil, nil
355}
356
357func handleFindFile(ctx context.Context, req *mcp.CallToolRequest, input FindInput) (*mcp.CallToolResult, any, error) {
358 gitCache := scanner.NewGitIgnoreCache(input.Path)

Callers 1

Calls 11

GitDiffInfoFunction · 0.92
NewGitIgnoreCacheFunction · 0.92
ScanFilesFunction · 0.92
FilterToChangedWithInfoFunction · 0.92
AnalyzeImpactFunction · 0.92
TreeFunction · 0.92
errorResultFunction · 0.85
textResultFunction · 0.85
stripANSIFunction · 0.70
ErrorMethod · 0.45
StringMethod · 0.45

Tested by 1