autogitc 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/autogitc +2 -1
  3. data/lib/autogitc.rb +7 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99784fe2ee80335aad903a67b88543706b6c3674de445406a69f268fca38a543
4
- data.tar.gz: 8c107ed10ed3c4d0f6776a0ae09d2c76c1d3b2e77dee7b144704a037e8413b3b
3
+ metadata.gz: 8338488482249d5ff2943379b1149b5da9db670f57821c6d827b1ba4b1c3f601
4
+ data.tar.gz: 271f9833f533852180a7598a0710006765a11b108a0d20d6876bb0b0985f81ce
5
5
  SHA512:
6
- metadata.gz: 3bd91f4c26f17dd0bf5414f47eba23f85f89d948b52843e4aad2daaf4fb0f527a39cc2504f66582760d3b3b70413db48b20f89a18dd13c4afb91e07c0f197e1c
7
- data.tar.gz: 71abbc7d1dd108dfe140c183a828a1683e850488012fbda1f7ac408110c6e55683d7d5c54df30096ce3015e7baf70743cf1fbbf942417497128ac2cb6c314a7e
6
+ metadata.gz: 7d182292cf4a0fe32fc1bb27e886a50a21a813a66902e07ee9557dbb6a6a3dc03f261723b2976414eddb990096f1cdaf3b4664cfb98c94e66d500cf96e8a0f1b
7
+ data.tar.gz: fcd92b63be81c3aae8b0678aea18b062cfffc5f070d18e280ce0133b59b44401d9f786fcccfefa41251d09f6a98add35f4c8614eb405264f3e6f18bdf2e41ac1
data/bin/autogitc CHANGED
@@ -3,6 +3,7 @@ require 'bundler/setup'
3
3
  require_relative '../lib/autogitc'
4
4
 
5
5
  no_commit = ARGV.include?('--nocommit') || ARGV.include?('--nc')
6
+ must_have_text = ARGV.find { |arg| arg.start_with?('--text=') }&.split('=')&.last
6
7
 
7
8
  puts 'Running autogitc...'
8
- Autogitc.main(no_commit: no_commit)
9
+ Autogitc.main(no_commit: no_commit, must_have_text: must_have_text)
data/lib/autogitc.rb CHANGED
@@ -15,7 +15,7 @@ module Autogitc
15
15
  `git diff --staged #{file_path}`
16
16
  end
17
17
 
18
- def self.generate_commit_message(changes_summary)
18
+ def self.generate_commit_message(changes_summary:, must_have_text: nil)
19
19
  uri = URI('https://api.openai.com/v1/chat/completions')
20
20
 
21
21
  http = Net::HTTP.new(uri.host, uri.port)
@@ -37,7 +37,7 @@ module Autogitc
37
37
  },
38
38
  {
39
39
  role: 'user',
40
- content: "Generate a conventional git commit message limited to 72 characters for the following changes in a JSON format with a key 'commit_message':\n\n#{changes_summary}"
40
+ content: "Generate a conventional git commit message limited to 72 characters for the following changes in a JSON format with a key 'commit_message', ensuring it includes the text: '#{must_have_text}':\n\n#{changes_summary}"
41
41
  }
42
42
  ],
43
43
  response_format: { "type": 'json_object' }
@@ -49,7 +49,7 @@ module Autogitc
49
49
  JSON.parse(output_text)['commit_message']
50
50
  end
51
51
 
52
- def self.main(no_commit: false)
52
+ def self.main(no_commit: false, must_have_text: nil)
53
53
  if openai_api_key.nil?
54
54
  puts 'No AUTOGITC_KEY key found in environment variables.'
55
55
  return
@@ -67,7 +67,10 @@ module Autogitc
67
67
  "Changes in #{file}:\n#{diff}\n"
68
68
  end.join("\n")
69
69
 
70
- commit_message = generate_commit_message(changes_summary)
70
+ commit_message = generate_commit_message(
71
+ changes_summary: changes_summary,
72
+ must_have_text: must_have_text
73
+ )
71
74
  puts 'Generated commit message:'
72
75
  puts commit_message
73
76
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autogitc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Goh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-27 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem simplifies the commit process by automatically generating descriptive
14
14
  commit messages based on the files that have been added to the Git staging area.