Skip to content

Commit 8cfa3a5

Browse files
committed
chore: bump version to 0.2.2 and refactor commit message validation
1 parent 26a0c2b commit 8cfa3a5

File tree

12 files changed

+228
-118
lines changed

12 files changed

+228
-118
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99

1010
# rspec failure tracking
1111
.rspec_status
12+
13+
# test files
14+
/test_project/
15+
test_keys.md

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.2] - 2025-03-22
9+
10+
### Fixed
11+
- Fixed API key storage in credential store when using `config set` command
12+
- Fixed commit message validation to properly handle different styles (conventional, minimal, simple, detailed)
13+
- Extended conventional commit scope pattern to allow dots in file names (e.g., `index.js`)
14+
- Improved AI prompts to consistently generate lowercase commit messages
15+
16+
### Added
17+
- Enhanced detailed commit style to include multi-line messages with:
18+
- Concise summary line
19+
- Detailed bullet points explaining changes
20+
- Technical context and reasoning
21+
822
## [0.2.1] - 2024-12-19
923

1024
### Fixed

exe/git-auto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "git_auto"
5+
require "git_auto/cli"
6+
7+
GitAuto::CLI.start(ARGV)

git_auto-0.2.1.gem

1 KB
Binary file not shown.

git_auto-0.2.2.gem

23 KB
Binary file not shown.

lib/git_auto/commands/commit_message_command.rb

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def initialize(options = {})
1919
@git_service = Services::GitService.new
2020
@ai_service = Services::AIService.new(@settings)
2121
@history_service = Services::HistoryService.new
22+
@validator = Validators::CommitMessageValidator.new(get_commit_style)
2223
@retry_count = 0
2324
end
2425

@@ -27,8 +28,11 @@ def execute
2728
status = @git_service.repository_status
2829
validate_repository(status)
2930

31+
# Get staged files
32+
staged_files = @git_service.get_staged_files
33+
3034
# Get and validate changes
31-
diff = @git_service.get_staged_diff
35+
diff = @git_service.get_staged_diff(staged_files)
3236
validate_changes(diff)
3337

3438
# Show diff preview if requested
@@ -112,6 +116,24 @@ def generate_message_with_style(diff, style, scope)
112116
message
113117
end
114118

119+
# Message Validation Methods
120+
def validate_message(message)
121+
result = @validator.validate(message)
122+
123+
if result[:errors].any?
124+
puts "\n❌ Validation errors:".red
125+
result[:errors].each { |error| puts @validator.format_error(error) }
126+
end
127+
128+
if result[:warnings].any?
129+
puts "\n⚠️ Suggestions:".yellow
130+
result[:warnings].each { |warning| puts @validator.format_warning(warning) }
131+
end
132+
133+
puts "\nPlease edit the message to fix these errors." if result[:errors].any?
134+
result
135+
end
136+
115137
# Message Handling Methods
116138
def handle_message(message, diff)
117139
formatted = Formatters::MessageFormatter.new.format(message)
@@ -124,37 +146,23 @@ def handle_message(message, diff)
124146
end
125147
end
126148

127-
def validate_message(message)
128-
validator = Validators::CommitMessageValidator.new
129-
validator.validate(message)
130-
end
131-
132149
def display_message_and_validation(formatted_message, validation)
133-
provider = @settings.get(:ai_provider)
134-
model = @settings.get(:ai_model)
135-
model_info = "(#{provider}/#{model})".light_black
136-
137-
puts "\n📝 Generated commit message #{model_info}:".blue
150+
puts "\n📝 Generated commit message (#{@settings.get(:ai_provider)}/#{@settings.get(:ai_model)}):".blue
138151
puts formatted_message
139152

140-
display_validation_errors(validation[:errors]) if validation[:errors].any?
153+
return unless validation[:errors].any? || validation[:warnings].any?
141154

142-
return unless validation[:warnings].any?
143-
144-
display_validation_warnings(validation[:warnings])
145-
end
155+
if validation[:errors].any?
156+
puts "\n❌ Validation errors:".red
157+
validation[:errors].each { |error| puts @validator.format_error(error) }
158+
end
146159

147-
def display_validation_errors(errors)
148-
puts "\n❌ Validation errors:".red
149-
validator = Validators::CommitMessageValidator.new
150-
errors.each { |error| puts validator.format_error(error) }
151-
puts "\nPlease edit the message to fix these errors.".yellow
152-
end
160+
if validation[:warnings].any?
161+
puts "\n⚠️ Suggestions:".yellow
162+
validation[:warnings].each { |warning| puts @validator.format_warning(warning) }
163+
end
153164

154-
def display_validation_warnings(warnings)
155-
puts "\n⚠️ Suggestions:".yellow
156-
validator = Validators::CommitMessageValidator.new
157-
warnings.each { |warning| puts validator.format_warning(warning) }
165+
puts "\nPlease edit the message to fix these errors." if validation[:errors].any?
158166
end
159167

160168
def prompt_user_action

lib/git_auto/commands/config_command.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,17 @@ def set_setting(key, value)
5858
exit 1
5959
end
6060

61-
@settings.set(key.to_sym, value)
62-
puts "✓ Setting '#{key}' updated to '#{value}'".green
61+
case key.to_s
62+
when "openai_api_key"
63+
@credential_store.store_api_key(value, "openai")
64+
puts "✓ OpenAI API key updated".green
65+
when "claude_api_key"
66+
@credential_store.store_api_key(value, "claude")
67+
puts "✓ Claude API key updated".green
68+
else
69+
@settings.set(key.to_sym, value)
70+
puts "✓ Setting '#{key}' updated to '#{value}'".green
71+
end
6372
end
6473

6574
def interactive_config

lib/git_auto/config/settings.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def get(key)
5252
@settings[key.to_sym]
5353
end
5454

55+
def set(key, value)
56+
@settings[key.to_sym] = value
57+
save
58+
end
59+
5560
def all
5661
@settings
5762
end

0 commit comments

Comments
 (0)