Class: OllamaAgent::Tools::GitCommit
- Defined in:
- lib/ollama_agent/tools/git_tools.rb
Overview
Git commit — requires approval
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#description, #input_schema, #name, #output_schema, #requires_approval, #risk_level
Instance Method Summary collapse
-
#call(args, context: {}) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength – staging branches + commit.
Methods inherited from Base
#initialize, #to_anthropic_schema, #to_ollama_schema, #to_s, tool_description, tool_name, tool_output_schema, tool_requires_approval, tool_risk, tool_schema
Constructor Details
This class inherits a constructor from OllamaAgent::Tools::Base
Instance Method Details
#call(args, context: {}) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength – staging branches + commit
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ollama_agent/tools/git_tools.rb', line 125 def call(args, context: {}) return "git_commit is disabled in read-only mode" if context[:read_only] root = context[:root] || Dir.pwd = args["message"].to_s.strip return "Error: commit message is required" if .empty? files = Array(args["files"]) all = args["all"] # Stage files if all git_run("git add -u", cwd: root) elsif files.any? safe_files = files.map { |f| Shellwords.shellescape(f) }.join(" ") git_run("git add #{safe_files}", cwd: root) end git_run("git commit -m #{Shellwords.shellescape()}", cwd: root) end |