27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/aigcm/commit_message_generator.rb', line 27
def generate(style_guide, context = [])
diff = GitDiff.new(dir: Dir.pwd, amend: @amend).generate_diff
return "No changes to commit" if diff.strip.empty?
check_repository_privacy unless @force_external
if diff.length > MAX_DIFF_SIZE
diff = diff[0...MAX_DIFF_SIZE] + "\n...[diff truncated]"
end
processed_context = process_context(context)
prompt = build_prompt(diff, style_guide, processed_context)
begin
response = @chat.ask(prompt)
response.content.strip
rescue StandardError => e
"Error generating commit message: #{e.message}"
end
end
|