Class: RubyCoded::Tools::GitCommitTool
- Inherits:
-
GitBaseTool
- Object
- RubyLLM::Tool
- BaseTool
- GitBaseTool
- RubyCoded::Tools::GitCommitTool
- Defined in:
- lib/ruby_coded/tools/git_commit_tool.rb
Overview
Create a non-interactive git commit.
Constant Summary
Constants inherited from GitBaseTool
RubyCoded::Tools::GitBaseTool::GIT_ENV, RubyCoded::Tools::GitBaseTool::MAX_OUTPUT_CHARS
Constants inherited from BaseTool
BaseTool::CONFIRM_RISK, BaseTool::DANGEROUS_RISK, BaseTool::SAFE_RISK
Instance Method Summary collapse
Methods inherited from GitBaseTool
#ensure_git_repo!, #format_git_result, #git_repo?, #run_git_command, #shell_join, #truncate_output
Methods inherited from BaseTool
Constructor Details
This class inherits a constructor from RubyCoded::Tools::BaseTool
Instance Method Details
#execute(message:, add_all: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby_coded/tools/git_commit_tool.rb', line 17 def execute(message:, add_all: false) msg = .to_s.strip return { error: "Commit message cannot be empty." } if msg.empty? if add_all add_result = run_git_command("add", "--all") return add_result if add_result.is_a?(Hash) end result = run_git_command("commit", "-m", msg) return enhance_commit_error(result) if result.is_a?(Hash) prefix = add_all ? "Staged all changes and created commit." : "Created commit." "#{prefix}\n#{result}" end |