Class: LLM::Tool::Git::Branch

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

Overview

The Branch class implements a tool that lists, creates, and deletes branches.

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(action: "list", name: nil, timeout: DEFAULT_TIMEOUT, cwd: Dir.getwd) ⇒ Hash

Parameters:

  • action (String) (defaults to: "list") —

    One of "list", "create", or "delete"

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

    The branch name

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

    The maximum time to allow git to run, in seconds

Returns:

  • (Hash)

Raises:

  • (ArgumentError) —

    When a branch name is required and not given



25
26
27
28
29
# File 'lib/llm/tools/git/branch.rb', line 25

def call(action: "list", name: nil, timeout: DEFAULT_TIMEOUT, cwd: Dir.getwd)
  Exec
    .new(env:)
    .call(command: "git", arguments: ["-C", cwd, *parse!(action:, name:)], timeout:)
end