From 3e94a71dcd4bac9417661df2ef74eb4685be6ee4 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 2 Aug 2023 18:26:39 +0300 Subject: [PATCH 1/2] commit_messages_str is used in all tools --- pr_agent/settings/pr_code_suggestions_prompts.toml | 5 +++++ pr_agent/settings/pr_information_from_user_prompts.toml | 5 +++++ pr_agent/settings/pr_questions_prompts.toml | 5 +++++ pr_agent/settings/pr_reviewer_prompts.toml | 5 +++++ pr_agent/settings/pr_update_changelog_prompts.toml | 5 +++++ pr_agent/tools/pr_code_suggestions.py | 1 + pr_agent/tools/pr_description.py | 3 +-- pr_agent/tools/pr_information_from_user.py | 1 + pr_agent/tools/pr_questions.py | 1 + pr_agent/tools/pr_reviewer.py | 1 + pr_agent/tools/pr_update_changelog.py | 1 + 11 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pr_agent/settings/pr_code_suggestions_prompts.toml b/pr_agent/settings/pr_code_suggestions_prompts.toml index b3a63f9a6..76a3cb6be 100644 --- a/pr_agent/settings/pr_code_suggestions_prompts.toml +++ b/pr_agent/settings/pr_code_suggestions_prompts.toml @@ -73,6 +73,11 @@ Description: '{{description}}' {%- if language %} Main language: {{language}} {%- endif %} +{%- if commit_messages_str %} + +Commit messages: +{{commit_messages_str}} +{%- endif %} The PR Diff: diff --git a/pr_agent/settings/pr_information_from_user_prompts.toml b/pr_agent/settings/pr_information_from_user_prompts.toml index f32ec7150..8d628f7a6 100644 --- a/pr_agent/settings/pr_information_from_user_prompts.toml +++ b/pr_agent/settings/pr_information_from_user_prompts.toml @@ -21,6 +21,11 @@ Description: '{{description}}' {%- if language %} Main language: {{language}} {%- endif %} +{%- if commit_messages_str %} + +Commit messages: +{{commit_messages_str}} +{%- endif %} The PR Git Diff: diff --git a/pr_agent/settings/pr_questions_prompts.toml b/pr_agent/settings/pr_questions_prompts.toml index cce35c97a..e306684d2 100644 --- a/pr_agent/settings/pr_questions_prompts.toml +++ b/pr_agent/settings/pr_questions_prompts.toml @@ -13,6 +13,11 @@ Description: '{{description}}' {%- if language %} Main language: {{language}} {%- endif %} +{%- if commit_messages_str %} + +Commit messages: +{{commit_messages_str}} +{%- endif %} The PR Git Diff: diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 87cfa29f5..9a6babf44 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -135,6 +135,11 @@ Description: '{{description}}' {%- if language %} Main language: {{language}} {%- endif %} +{%- if commit_messages_str %} + +Commit messages: +{{commit_messages_str}} +{%- endif %} {%- if question_str %} ###### diff --git a/pr_agent/settings/pr_update_changelog_prompts.toml b/pr_agent/settings/pr_update_changelog_prompts.toml index f12b6c65a..78b6a0b53 100644 --- a/pr_agent/settings/pr_update_changelog_prompts.toml +++ b/pr_agent/settings/pr_update_changelog_prompts.toml @@ -19,6 +19,11 @@ Description: '{{description}}' {%- if language %} Main language: {{language}} {%- endif %} +{%- if commit_messages_str %} + +Commit messages: +{{commit_messages_str}} +{%- endif %} The PR Diff: diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 71aecd7a8..1816088f8 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -34,6 +34,7 @@ def __init__(self, pr_url: str, cli_mode=False, args: list = None): "diff": "", # empty diff for initial calculation "num_code_suggestions": get_settings().pr_code_suggestions.num_code_suggestions, "extra_instructions": get_settings().pr_code_suggestions.extra_instructions, + "commit_messages_str": self.git_provider.get_commit_messages(), } self.token_handler = TokenHandler(self.git_provider.pr, self.vars, diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index aaf14227d..7f39a8b87 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -27,7 +27,6 @@ def __init__(self, pr_url: str, args: list = None): self.main_pr_language = get_main_pr_language( self.git_provider.get_languages(), self.git_provider.get_files() ) - commit_messages_str = self.git_provider.get_commit_messages() # Initialize the AI handler self.ai_handler = AiHandler() @@ -40,7 +39,7 @@ def __init__(self, pr_url: str, args: list = None): "language": self.main_pr_language, "diff": "", # empty diff for initial calculation "extra_instructions": get_settings().pr_description.extra_instructions, - "commit_messages_str": commit_messages_str + "commit_messages_str": self.git_provider.get_commit_messages() } # Initialize the token handler diff --git a/pr_agent/tools/pr_information_from_user.py b/pr_agent/tools/pr_information_from_user.py index 10d323811..c049250fd 100644 --- a/pr_agent/tools/pr_information_from_user.py +++ b/pr_agent/tools/pr_information_from_user.py @@ -24,6 +24,7 @@ def __init__(self, pr_url: str, args: list = None): "description": self.git_provider.get_pr_description(), "language": self.main_pr_language, "diff": "", # empty diff for initial calculation + "commit_messages_str": self.git_provider.get_commit_messages(), } self.token_handler = TokenHandler(self.git_provider.pr, self.vars, diff --git a/pr_agent/tools/pr_questions.py b/pr_agent/tools/pr_questions.py index 33923776e..959bebe71 100644 --- a/pr_agent/tools/pr_questions.py +++ b/pr_agent/tools/pr_questions.py @@ -27,6 +27,7 @@ def __init__(self, pr_url: str, args=None): "language": self.main_pr_language, "diff": "", # empty diff for initial calculation "questions": self.question_str, + "commit_messages_str": self.git_provider.get_commit_messages(), } self.token_handler = TokenHandler(self.git_provider.pr, self.vars, diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index f8610863c..e4d526b5c 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -59,6 +59,7 @@ def __init__(self, pr_url: str, is_answer: bool = False, args: list = None): 'question_str': question_str, 'answer_str': answer_str, "extra_instructions": get_settings().pr_reviewer.extra_instructions, + "commit_messages_str": self.git_provider.get_commit_messages(), } self.token_handler = TokenHandler( diff --git a/pr_agent/tools/pr_update_changelog.py b/pr_agent/tools/pr_update_changelog.py index 91b4da9e8..1ec627095 100644 --- a/pr_agent/tools/pr_update_changelog.py +++ b/pr_agent/tools/pr_update_changelog.py @@ -38,6 +38,7 @@ def __init__(self, pr_url: str, cli_mode=False, args=None): "changelog_file_str": self.changelog_file_str, "today": date.today(), "extra_instructions": get_settings().pr_update_changelog.extra_instructions, + "commit_messages_str": self.git_provider.get_commit_messages(), } self.token_handler = TokenHandler(self.git_provider.pr, self.vars, From eb143ec851642ae45286d3a1b9dea1fecc1aefe5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:32:15 +0000 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dda62bb3..d85919699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2023-08-02 + +### Enhanced +- Updated several tools in the `pr_agent` package to use commit messages in their functionality. +- Commit messages are now retrieved and stored in the `vars` dictionary for each tool. +- Added a section to display the commit messages in the prompts of various tools. + ## 2023-08-01 2023-08-01