Class: RubyLLM::Toolbox::Tools::GitShow
- Includes:
- GitHelpers
- Defined in:
- lib/ruby_llm/toolbox/tools/git_show.rb
Overview
SAFE. Shows a commit (message + diff) or the contents of a file at a given ref. Read-only. External diff drivers and textconv are disabled.
Constant Summary
Constants included from GitHelpers
RubyLLM::Toolbox::Tools::GitHelpers::GIT_ENV, RubyLLM::Toolbox::Tools::GitHelpers::REF_RE
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from GitHelpers
#git_result, #repo_relative, #run_git, #valid_ref?
Methods inherited from Base
#call, exec_tool!, exec_tool?, #initialize, #name
Constructor Details
This class inherits a constructor from RubyLLM::Toolbox::Base
Instance Method Details
#execute(ref: "HEAD", path: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby_llm/toolbox/tools/git_show.rb', line 25 def execute(ref: "HEAD", path: nil) ref = ref.to_s.strip ref = "HEAD" if ref.empty? return error("invalid ref: #{ref.inspect}", code: :bad_ref) unless valid_ref?(ref) rel = repo_relative(path) args = if rel ["show", "#{ref}:#{rel}"] else ["show", "--no-ext-diff", "--no-textconv", "--stat", "--patch", ref] end out, err, status = run_git(*args) result = git_result(out, err, status) return result if result.is_a?(Hash) truncate(result) rescue Safety::PathJail::Jailbreak => e error(e., code: :path_denied) end |