Method: Committer::CommitGenerator#parse_response
- Defined in:
- lib/committer/commit_generator.rb
#parse_response(response) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/committer/commit_generator.rb', line 38 def parse_response(response) text = response.dig('content', 0, 'text') # If user didn't provide context, response should only be a summary line if @commit_context.nil? || @commit_context.empty? { summary: text.strip, body: nil } else # Split the response into summary and body = text.split("\n\n", 2) summary = [0].strip body = [1]&.strip # Wrap body text at 80 characters body = body.gsub(/(.{1,80})(\s+|$)/, "\\1\n").strip if body { summary: summary, body: body } end end |