Class: RubyLLM::Toolbox::Tools::GitCheckout
- Includes:
- GitHelpers
- Defined in:
- lib/ruby_llm/toolbox/tools/git_checkout.rb
Overview
EXEC. Switches branches or creates a new branch in the repo at fs_root. The ref is validated (no leading dash, ref-safe characters only) so it can’t smuggle git options.
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:, create: false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby_llm/toolbox/tools/git_checkout.rb', line 26 def execute(ref:, create: false) return error("invalid ref: #{ref.inspect}", code: :bad_ref) unless valid_ref?(ref) args = ["checkout"] args << "-b" if create args << ref out, err, status = run_git(*args) result = git_result(out, err, status) return result if result.is_a?(Hash) # git prints checkout feedback to stderr on success. truncate([out, err].map(&:strip).reject(&:empty?).join("\n")) end |