commit_ai 0.1.9 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 163dcacd836441ac91cfa6903ab7795889e9db51562cbc9055bc1cddc3998dca
4
- data.tar.gz: 489a51e90bad0f1901cc751c95545e9dbb2491e72811f7773062ad8f86dd3cea
3
+ metadata.gz: 129b030b1c188414e7b7c6bbdff473433185e1d0a61bab5c4a161598def6280a
4
+ data.tar.gz: 0dce0887496b90ed4f8ad9b5c3e1225fa230cc6fe445a0a232c38998503560a6
5
5
  SHA512:
6
- metadata.gz: '010013338f7f4be32cb1a05920fa6749a953c9c15d29da3a396884baaf694ba6fd1456ab2ff9a75845f7a38938f5b0f4d58c7275a5f2074ebbe462bab3a4e22f'
7
- data.tar.gz: b6686fd820b574f4c66458abe2686b9cc168dc4c13190c19035c938e87db91ffa4a3771bd7803e7dea23ea3741081ed059fd58b9c2019934da6581cde90bcf28
6
+ metadata.gz: 10fc57e0ec0294f3dbdace2f37a339f728792dbbe69c3af0116e0f93edfc455dcecaa4a59e3cc840711b26894e27f4119152ff0cce56b4e55e8ea4993e55dfe2
7
+ data.tar.gz: 7ca358b753565846326094d512ab70f4293e18d3c3c37f8c77f33d3b7d6cc473cb43e4a47eb233867f8d70a5fe0812184cba8c91b4ce3bc88b00abc6fb2dfbf7
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommitAi
4
- VERSION = "0.1.9"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/commit_ai.rb CHANGED
@@ -10,34 +10,43 @@ class CommitAI
10
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
- commit_message = generate_commit_message(diff, message_style, user_description)
26
- puts "Generated Commit Message:\n#{commit_message}"
27
- print "Do you want to proceed with the commit? (y/n), regenerate (r), or edit (e): "
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
- else
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
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.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Vitug