Class: AIRefactor::Refactors::Project::WriteChangelogFromHistory
- Inherits:
-
BaseRefactor
- Object
- BaseRefactor
- AIRefactor::Refactors::Project::WriteChangelogFromHistory
show all
- Defined in:
- lib/ai_refactor/refactors/project/write_changelog_from_history.rb
Instance Attribute Summary
Attributes inherited from BaseRefactor
#ai_client, #failed_message, #input_content, #input_file, #logger, #options
Class Method Summary
collapse
Instance Method Summary
collapse
inherited, #initialize, refactor_name
Class Method Details
.command_line_options ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/ai_refactor/refactors/project/write_changelog_from_history.rb', line 37
def self.command_line_options
[
{
key: :git_commit_count,
long: "--commits N",
type: Integer,
help: "The number of commits to analyse when creating the changelog entries (defaults to 3)"
}
]
end
|
.description ⇒ Object
7
8
9
|
# File 'lib/ai_refactor/refactors/project/write_changelog_from_history.rb', line 7
def self.description
"Write changelog entries from the git history"
end
|
11
12
13
|
# File 'lib/ai_refactor/refactors/project/write_changelog_from_history.rb', line 11
def self.takes_input_files?
false
end
|
Instance Method Details
#default_output_path ⇒ Object
33
34
35
|
# File 'lib/ai_refactor/refactors/project/write_changelog_from_history.rb', line 33
def default_output_path
nil
end
|
#run ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/ai_refactor/refactors/project/write_changelog_from_history.rb', line 15
def run
logger.verbose "Creating changelog entries for project from #{options[:git_commit_count] || 3} commits..."
logger.verbose "Write output to #{output_file_path}..." if output_file_path
self.input_content = `git log -#{options[:git_commit_count] || 3} --pretty=format:"%ci %d %s"`.split("\n").map { |line| "- #{line}" }.join("\n")
logger.debug "\nInput messages: \n#{input_content}\n\n"
begin
output_content = process!(strip_ticks: false)
rescue => e
logger.error "Failed to process: #{e.message}"
return false
end
return false unless output_content
output_file_path ? true : output_content
end
|