Class: LLM::Tool::Git::Diff

Inherits:
LLM::Tool::Git show all
Defined in:
lib/llm/tools/git/diff.rb

Overview

The Diff class implements a tool that shows the changes between commits, the index, and the working tree.

Constant Summary

Constants inherited from LLM::Tool::Git

DEFAULT_TIMEOUT

Instance Method Summary collapse

Methods inherited from LLM::Tool

NotFound, a2a, a2a?, #a2a?, abstract!, abstract?, clear_registry!, description, find_by_name!, #function, function, inherited, mcp, #mcp?, mcp?, name, #on_cancel, #on_interrupt, params, register, registry, set, subclasses, unregister

Methods included from Param

#defaults, #param, #required

Methods included from Function::Registry

#clear_registry!, #find_by_name, #lock, #register, #registry, #registry_key, #tool_name, #unregister

Instance Method Details

#call(rev: nil, path: nil, staged: false, stat: false, context: nil, timeout: DEFAULT_TIMEOUT, cwd: Dir.getwd) ⇒ Hash

Parameters:

  • rev (String, nil) (defaults to: nil) —

    An optional revision to diff against

  • path (String, nil) (defaults to: nil) —

    An optional path

  • staged (Boolean) (defaults to: false) —

    Whether to diff the index

  • stat (Boolean) (defaults to: false) —

    Whether to show a diffstat instead of a patch

  • context (Integer, nil) (defaults to: nil) —

    The number of context lines to show

  • timeout (Integer) (defaults to: DEFAULT_TIMEOUT) —

    The maximum time to allow git to run, in seconds

Returns:

  • (Hash)


33
34
35
36
37
# File 'lib/llm/tools/git/diff.rb', line 33

def call(rev: nil, path: nil, staged: false, stat: false, context: nil, timeout: DEFAULT_TIMEOUT, cwd: Dir.getwd)
  Exec
    .new(env:)
    .call(command: "git", arguments: ["-C", cwd, *parse!(rev:, path:, staged:, stat:, context:)], timeout:)
end