commit_ai 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c87ad68cc8d4e50fd42fe7103ccb29775b317ec8bcadd565ae0bfd782803047
4
- data.tar.gz: 2aad903b0f30d5332854b909409b168f6c3b90223e9c51954e454f69864f9592
3
+ metadata.gz: 4ba0524e5f1c3fa71ddc632dec527ff381d100a18241cb43934199f2a2e051dc
4
+ data.tar.gz: 95f336051d80c86068a93d1138c19c81978bfa631c7c2dad7878df4e251b053e
5
5
  SHA512:
6
- metadata.gz: ae68dd9f2e8653787744212093d735099f8b02ed01850f15f76c01749d78bac7b9f9d662e011dd38ab1e732f4f335947edaa62c8f608cbbbbd8d23d5bdfdbf1b
7
- data.tar.gz: e3ca4b11e589375783c2fc06d6b648d2db313dee57e08b525ca55ccb6e4efd44ca97e3fbbe8ee7ead8c6c526a8ff7f1597bea1233045444777f611a67b63bfa3
6
+ metadata.gz: 84ebdca607930387d57e1cffac6bb7ee221ac12aaa0d25c54889064c89c9560cea15cccbb2c654eae3a2e2dd3d4d4c1195289265c2c1d17a2fe041efdb79ad91
7
+ data.tar.gz: 703b364032b8a370be4c3fbdb1f27535a38d14749e98cd2282ce89c8f77e648af48cf9a5f66c028ce8b73d4315ed58f86a13cf34d1763cf2ea4a0fd106e7a19c
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommitAi
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/commit_ai.rb CHANGED
@@ -5,38 +5,8 @@ class CommitAI
5
5
  @client = OpenAI::Client.new(access_token: ENV['OPENAI_ACCESS_TOKEN'])
6
6
  end
7
7
 
8
- def analyze_codebase
9
- codebase_summary = ""
10
-
11
- files = Dir.glob("**/*").reject { |f| f =~ %r{/(node_modules|\.git|\.DS_Store)} }
12
-
13
- files.each do |file|
14
- next unless File.file?(file)
15
-
16
- file_content = File.read(file)
17
- codebase_summary += "File: #{file}\n"
18
- codebase_summary += "Content Preview:\n#{file_content[0..500]}\n"
19
- codebase_summary += "\n---\n"
20
- end
21
-
22
- codebase_summary
23
- end
24
-
25
- def analyze_git_history
26
- git_history = `git log --pretty=format:"%h - %an, %ar: %s"`.strip
27
- if git_history.empty?
28
- "No commits found"
29
- else
30
- git_history
31
- end
32
- end
33
-
34
8
  def generate_commit_message(diff)
35
- codebase_summary = analyze_codebase
36
- git_history = analyze_git_history
37
9
  prompt = <<~PROMPT
38
- This is the codebase summary: #{codebase_summary}
39
- This is the git history: #{git_history}
40
10
  This is the git diff: #{diff}
41
11
 
42
12
  Please generate a **single-line** commit message that is concise and follows best practices.
@@ -71,7 +41,7 @@ class CommitAI
71
41
  loop do
72
42
  commit_message = generate_commit_message(diff)
73
43
  puts "Generated Commit Message: #{commit_message}"
74
- print "Do you want to proceed with the commit? (y/n) or regenerate (r): "
44
+ print "Do you want to proceed with the commit? (y/n), regenerate (r), or edit (e): "
75
45
  response = STDIN.gets.chomp
76
46
  case response.downcase
77
47
  when 'y'
@@ -79,6 +49,9 @@ class CommitAI
79
49
  break
80
50
  when 'r'
81
51
  next
52
+ when 'e'
53
+ system("git commit -m '#{commit_message}' -e")
54
+ break
82
55
  else
83
56
  puts "Commit aborted."
84
57
  break
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commit_ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Vitug
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-02 00:00:00.000000000 Z
11
+ date: 2024-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
@@ -25,8 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: Commit AI automates the generation of insightful one-liner commit messages
28
- by analyzing staged git diffs and the codebase with the help of OpenAI's advanced
29
- language models.
28
+ by analyzing staged git diffs with the help of OpenAI's advanced language models.
30
29
  email:
31
30
  - ken@narralabs.com
32
31
  executables: