commit_ai 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/commit_ai/version.rb +1 -1
- data/lib/commit_ai.rb +22 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 129b030b1c188414e7b7c6bbdff473433185e1d0a61bab5c4a161598def6280a
|
4
|
+
data.tar.gz: 0dce0887496b90ed4f8ad9b5c3e1225fa230cc6fe445a0a232c38998503560a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10fc57e0ec0294f3dbdace2f37a339f728792dbbe69c3af0116e0f93edfc455dcecaa4a59e3cc840711b26894e27f4119152ff0cce56b4e55e8ea4993e55dfe2
|
7
|
+
data.tar.gz: 7ca358b753565846326094d512ab70f4293e18d3c3c37f8c77f33d3b7d6cc473cb43e4a47eb233867f8d70a5fe0812184cba8c91b4ce3bc88b00abc6fb2dfbf7
|
data/lib/commit_ai/version.rb
CHANGED
data/lib/commit_ai.rb
CHANGED
@@ -7,37 +7,46 @@ class CommitAI
|
|
7
7
|
|
8
8
|
def execute
|
9
9
|
system("git add --all")
|
10
|
-
diff = `git diff -
|
10
|
+
diff = `git diff -U10 --staged`
|
11
11
|
|
12
12
|
if diff.empty?
|
13
|
-
puts "No changes to commit."
|
13
|
+
puts colorize("No changes to commit. No need to proceed.", 31)
|
14
14
|
return
|
15
15
|
end
|
16
16
|
|
17
|
-
puts "Please provide a brief description of the change made (optional):
|
17
|
+
puts colorize("Please provide a brief description of the change made (optional):", 36)
|
18
18
|
user_description = STDIN.gets.chomp
|
19
19
|
|
20
|
-
puts "Do you want a multi-line commit message? (y/n) (optional):
|
20
|
+
puts colorize("Do you want a multi-line commit message? (y/n) (optional):", 36)
|
21
21
|
message_style_input = STDIN.gets.chomp.downcase
|
22
22
|
message_style = message_style_input == 'y' ? 'multi' : 'single'
|
23
23
|
|
24
|
+
commit_message = generate_commit_message(diff, message_style, user_description)
|
24
25
|
loop do
|
25
|
-
|
26
|
-
puts "
|
27
|
-
|
26
|
+
puts colorize("\nGenerated Commit Message:\n#{commit_message}", 32)
|
27
|
+
puts ""
|
28
|
+
puts colorize("Do you want to proceed with the commit? (y/n), regenerate (r), or edit (e):", 36)
|
28
29
|
response = STDIN.gets.chomp
|
29
30
|
case response.downcase
|
30
31
|
when 'y'
|
31
32
|
system("git commit -m '#{commit_message}'")
|
33
|
+
puts colorize("Commit successful!", 32)
|
32
34
|
break
|
33
35
|
when 'r'
|
36
|
+
commit_message = generate_commit_message(diff, message_style, user_description)
|
37
|
+
puts colorize("Regenerating commit message...", 33)
|
34
38
|
next
|
35
39
|
when 'e'
|
36
40
|
system("git commit -m '#{commit_message}' -e")
|
41
|
+
puts colorize("Commit successful after editing!", 32)
|
37
42
|
break
|
38
|
-
|
39
|
-
puts "Commit aborted."
|
43
|
+
when 'n'
|
44
|
+
puts colorize("Commit aborted. No changes committed.", 31)
|
40
45
|
break
|
46
|
+
else
|
47
|
+
puts colorize("Invalid input. Please try again.", 31)
|
48
|
+
puts ""
|
49
|
+
next
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
@@ -107,4 +116,8 @@ class CommitAI
|
|
107
116
|
|
108
117
|
minified_diff.join
|
109
118
|
end
|
119
|
+
|
120
|
+
def colorize(text, color_code)
|
121
|
+
"\e[#{color_code}m#{text}\e[0m"
|
122
|
+
end
|
110
123
|
end
|