commit_ai 0.1.3 → 0.1.5

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: 3bb64bbcabd9361061a9237413b2c37988f36c329e38bf393d7625ebfa3f807e
4
- data.tar.gz: 237c8b7a7c55e220736de318526c09b88be1796b43bf5dad88d5e7c14526171b
3
+ metadata.gz: ddf3fb295ff77ec358d0e1ecc827c0d4f4b5ff1794d8f9dfd506f2f9935d3fba
4
+ data.tar.gz: 46b05940dedf439c6dd42565da3532b6cdb440de9df2328246587cebcf871b49
5
5
  SHA512:
6
- metadata.gz: 4e6039b3cc10882fa785c1ab18889d214ccff0ed815cf91a52aadee91aca9a95961a4404dd25cfed045b70b4f947b88240f9046493546a6a2a7b03a217978c60
7
- data.tar.gz: 12b1e41db6c9f7b91f4e5dd070135eb04d063ff35b5167883b49ad71673a3c71ed6e6a8555a20a36696127e0352f511e4be9d135873f81d76b3dc72ef8898f21
6
+ metadata.gz: 0ce55a243201339017d080042090d43d42871a56d68cec162213c2bc3095123624760ac4c9842434e5145c1e843a73fb1b6a141fb247bb0285e54c2b17aa7789
7
+ data.tar.gz: 5f34f7b5abdba14fc58af9e7040a8382136ae31a2078b142ecd03c063b3293459f4cc49ad1b02eeb48898ecaa77912480287564e00b31cc3717b4f90c97a3f23
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommitAi
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
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.
@@ -63,6 +33,11 @@ class CommitAI
63
33
  system("git add --all")
64
34
  diff = `git diff --staged`
65
35
 
36
+ if diff.empty?
37
+ puts "No changes to commit."
38
+ return
39
+ end
40
+
66
41
  loop do
67
42
  commit_message = generate_commit_message(diff)
68
43
  puts "Generated Commit Message: #{commit_message}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commit_ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Vitug
@@ -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: