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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43859139f57b17b863cc8b3f5a0ac1821bcde304f91071219b6ecef84b5ca3ff
4
- data.tar.gz: fc3870e5b895d0a060bd39bd97f4eb6cabb32fe1ce30b39062dc3accc186e67a
3
+ metadata.gz: 129b030b1c188414e7b7c6bbdff473433185e1d0a61bab5c4a161598def6280a
4
+ data.tar.gz: 0dce0887496b90ed4f8ad9b5c3e1225fa230cc6fe445a0a232c38998503560a6
5
5
  SHA512:
6
- metadata.gz: f37fdd6fcf6420ef418cbf74832935e2c93409553d892e7a072c3521fa4fbae621ec786ff3d07c736aea064e87a5816b70e09359f4b28a81eeec78ead6898727
7
- data.tar.gz: 3a7ede99534471bb07fc363c550c56ea917fd73b6d9251c670335327c63b99648b8cb521e4c4043e0bc5a231fb30252f8fcc063a84e80e7a373996e038d1b2ee
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.8"
4
+ VERSION = "0.2.0"
5
5
  end
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 -U99999 --staged`
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.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Vitug