Module: Committer::PromptTemplates
- Defined in:
- lib/committer/prompt_templates.rb
Class Method Summary collapse
- .build_prompt(diff, scopes, commit_context) ⇒ Object
- .build_prompt_summary_and_body ⇒ Object
- .build_prompt_summary_only ⇒ Object
- .build_scopes_list(scopes) ⇒ Object
- .load_prompt(file_name) ⇒ Object
Class Method Details
.build_prompt(diff, scopes, commit_context) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/committer/prompt_templates.rb', line 5 def self.build_prompt(diff, scopes, commit_context) prompt_template = if commit_context.nil? || commit_context.empty? Committer::PromptTemplates.build_prompt_summary_only else Committer::PromptTemplates.build_prompt_summary_and_body end prompt_template .gsub('{{DIFF}}', diff) .gsub('{{SCOPES}}', build_scopes_list(scopes)) .gsub('{{CONTEXT}}', commit_context || '') end |
.build_prompt_summary_and_body ⇒ Object
29 30 31 |
# File 'lib/committer/prompt_templates.rb', line 29 def self.build_prompt_summary_and_body load_prompt(Committer::Config::Constants::COMMIT_MESSAGE_AND_BODY_PROMPT_FILE_NAME) end |
.build_prompt_summary_only ⇒ Object
25 26 27 |
# File 'lib/committer/prompt_templates.rb', line 25 def self.build_prompt_summary_only load_prompt(Committer::Config::Constants::COMMIT_MESSAGE_ONLY_PROMPT_FILE_NAME) end |
.build_scopes_list(scopes) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/committer/prompt_templates.rb', line 17 def self.build_scopes_list(scopes) return 'DO NOT include a scope in your commit message' if scopes.empty? scope_list = "\nScopes:\n#{scopes.map { |s| "- #{s}" }.join("\n")}" "- Choose an appropriate scope from the list above if relevant to the change \n#{scope_list}" end |
.load_prompt(file_name) ⇒ Object
33 34 35 |
# File 'lib/committer/prompt_templates.rb', line 33 def self.load_prompt(file_name) Committer::Config::Accessor.instance.read_path_prioritized_file(file_name) end |