dorian-commit 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/commit +34 -27
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cfd254ac72b0cb783a5617779fb203ed8fe84cec8685702a9f52ab18ac6de0b
4
- data.tar.gz: 8158f5df736374fa3c9fc3e203755344dcdd93610d42227c127da25f14d577e1
3
+ metadata.gz: 96ab8fd00e486fb48cb313023efd6ecf14763427593916b018304628f468eb05
4
+ data.tar.gz: 3bae8a19f1e528450a06600b08a7b4e6e63ad9e80dd742b79984edde5a08f1f2
5
5
  SHA512:
6
- metadata.gz: a328add85459b999de4436e92db6ea24cfd03912d3c0672fabe13823d24a88cfbe247db4bb2b0a2c43b1be596e3144ca2cbb5d2e67015bb25cdbcce7b480d1bb
7
- data.tar.gz: 9dc85ba07932fc0be0c5781b4c5d6d94bbe5de98d686c61dc8cd234f9982608f350bd3b8436735ca48c483d2466f784c50d09994ac44325b4bf9b30a17adae91
6
+ metadata.gz: be08309f81e4dfa4100f8186e7de3a3cd4e6b95dbb2dab6b17f434918f92c8e73e30b2830ffaaa9d84c87318c4beaa181a2004bb92f7f3e1a65991646a62c901
7
+ data.tar.gz: 7eca41f69e2d35094437282a05dcd0c26b64c0a8ddf35f23e71f554765c4e7ea9fce849396bfe27c93b218915e120d220892e50f7fec9f9f63e1d2fcc5906a59
data/bin/commit CHANGED
@@ -24,12 +24,25 @@ PROMPT_2 = "for the following diff:"
24
24
  PROMPT_3 = "for the following git status:"
25
25
  PROMPT_4 = "for the following comment:"
26
26
 
27
- parsed = Dorian::Arguments.parse(tokens: { type: :integer, alias: :t, default: 1000 }, version: { alias: :v }, help: { alias: :h })
27
+ parsed =
28
+ Dorian::Arguments.parse(
29
+ tokens: {
30
+ type: :integer,
31
+ alias: :t,
32
+ default: 1000
33
+ },
34
+ version: {
35
+ alias: :v
36
+ },
37
+ help: {
38
+ alias: :h
39
+ }
40
+ )
28
41
 
29
42
  abort parsed.help if parsed.options.help
30
43
 
31
44
  if parsed.options.version
32
- abort File.read(File.expand_path("../../VERSION", __FILE__))
45
+ abort File.read(File.expand_path("../VERSION", __dir__))
33
46
  end
34
47
 
35
48
  content_2 = `git diff --staged`
@@ -43,34 +56,28 @@ encoder = Tiktoken.encoding_for_model("gpt-4o")
43
56
 
44
57
  content_2_encoded = encoder.encode(content_2)
45
58
 
46
- if content_2_encoded.length > parsed.options.tokens
47
- messages_2 = []
48
- else
49
- messages_2 = [
50
- { role: :system, content: PROMPT_2 },
51
- { role: :user, content: content_2 }
52
- ]
53
- end
59
+ messages_2 =
60
+ if content_2_encoded.length > parsed.options.tokens
61
+ []
62
+ else
63
+ [{ role: :system, content: PROMPT_2 }, { role: :user, content: content_2 }]
64
+ end
54
65
 
55
66
  content_3_encoded = encoder.encode(content_3)
56
67
 
57
- if content_3_encoded.length > parsed.options.tokens
58
- messages_3 = []
59
- else
60
- messages_3 = [
61
- { role: :system, content: PROMPT_3 },
62
- { role: :user, content: content_3 },
63
- ]
64
- end
65
-
66
- if content_4.empty?
67
- messages_4 = []
68
- else
69
- messages_4 = [
70
- { role: :system, content: PROMPT_4 },
71
- { role: :user, content: content_4 }
72
- ]
73
- end
68
+ messages_3 =
69
+ if content_3_encoded.length > parsed.options.tokens
70
+ []
71
+ else
72
+ [{ role: :system, content: PROMPT_3 }, { role: :user, content: content_3 }]
73
+ end
74
+
75
+ messages_4 =
76
+ if content_4.empty?
77
+ []
78
+ else
79
+ [{ role: :system, content: PROMPT_4 }, { role: :user, content: content_4 }]
80
+ end
74
81
 
75
82
  uri = URI.parse("https://api.openai.com/v1/chat/completions")
76
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-25 00:00:00.000000000 Z
11
+ date: 2024-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dorian-arguments
@@ -71,9 +71,9 @@ require_paths:
71
71
  - lib
72
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 3.3.4
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="