Module: Aigcm
- Defined in:
- lib/aigcm.rb,
lib/aigcm/options.rb,
lib/aigcm/version.rb,
lib/aigcm/git_diff.rb,
lib/aigcm/style_guide.rb,
lib/aigcm/commit_message_generator.rb
Defined Under Namespace
Classes: CommitMessageGenerator, Error, GitDiff, Options, StyleGuide
Constant Summary
collapse
- COMMIT_MESSAGE_FILE =
'.aigcm_msg'
- RECENT_THRESHOLD =
60
- VERSION =
"0.3.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.parsed_options ⇒ Object
Returns the value of attribute parsed_options.
21
22
23
|
# File 'lib/aigcm.rb', line 21
def parsed_options
@parsed_options
end
|
Class Method Details
.amend? ⇒ Boolean
55
56
57
|
# File 'lib/aigcm.rb', line 55
def amend?
parsed_options[:amend]
end
|
.dry? ⇒ Boolean
51
52
53
|
# File 'lib/aigcm.rb', line 51
def dry?
parsed_options[:dry]
end
|
.model ⇒ Object
59
60
61
|
# File 'lib/aigcm.rb', line 59
def model
parsed_options[:model]
end
|
.provider ⇒ Object
63
64
65
|
# File 'lib/aigcm.rb', line 63
def provider
parsed_options[:provider]
end
|
.run(test_mode: false) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/aigcm.rb', line 23
def run(test_mode: false)
@parsed_options = Options.parse
dir = Dir.pwd
if amend?
system('git commit --amend')
return
end
commit_message = check_recent_commit(dir, dry?)
commit_message ||= generate_commit_message(dir)
perform_commit(dir, commit_message)
rescue OptionParser::InvalidOption => e
STDERR.puts "Error: '#{e.message}'"
exit 1
rescue GitDiff::Error => e
puts "Git error: #{e.message}"
exit 1
rescue StandardError => e
puts "Error: #{e.message}"
exit 1
end
|