diff --git a/pr_agent/config_loader.py b/pr_agent/config_loader.py index 69d20d88..5716fe8a 100644 --- a/pr_agent/config_loader.py +++ b/pr_agent/config_loader.py @@ -19,7 +19,7 @@ settings = Dynaconf( "settings/pr_description_prompts.toml", "settings/pr_code_suggestions_prompts.toml", "settings/pr_information_from_user_prompts.toml", - "settings/pr_update_changelog.toml", + "settings/pr_update_changelog_prompts.toml", "settings_prod/.secrets.toml" ]] ) diff --git a/pr_agent/settings/pr_update_changelog.toml b/pr_agent/settings/pr_update_changelog_prompts.toml similarity index 90% rename from pr_agent/settings/pr_update_changelog.toml rename to pr_agent/settings/pr_update_changelog_prompts.toml index 91413010..f12b6c65 100644 --- a/pr_agent/settings/pr_update_changelog.toml +++ b/pr_agent/settings/pr_update_changelog_prompts.toml @@ -4,6 +4,12 @@ Your task is to update the CHANGELOG.md file of the project, to shortly summariz - The output should match the existing CHANGELOG.md format, style and conventions, so it will look like a natural part of the file. For example, if previous changes were summarized in a single line, you should do the same. - Don't repeat previous changes. Generate only new content, that is not already in the CHANGELOG.md file. - Be general, and avoid specific details, files, etc. The output should be minimal, no more than 3-4 short lines. Ignore non-relevant subsections. + +{%- if extra_instructions %} + +Extra instructions from the user: +{{ extra_instructions }} +{%- endif %} """ user="""PR Info: diff --git a/pr_agent/tools/pr_update_changelog.py b/pr_agent/tools/pr_update_changelog.py index eea77e30..a4f93978 100644 --- a/pr_agent/tools/pr_update_changelog.py +++ b/pr_agent/tools/pr_update_changelog.py @@ -10,6 +10,7 @@ from pr_agent.algo.ai_handler import AiHandler from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models from pr_agent.algo.token_handler import TokenHandler from pr_agent.config_loader import settings +from pr_agent.algo.utils import update_settings_from_args from pr_agent.git_providers import get_git_provider, GithubProvider from pr_agent.git_providers.git_provider import get_main_pr_language @@ -23,7 +24,8 @@ class PRUpdateChangelog: self.main_language = get_main_pr_language( self.git_provider.get_languages(), self.git_provider.get_files() ) - self.commit_changelog = self._parse_args(args, settings) + update_settings_from_args(args) + self.commit_changelog = settings.pr_update_changelog.push_changelog_changes self._get_changlog_file() # self.changelog_file_str self.ai_handler = AiHandler() self.patches_diff = None @@ -37,7 +39,7 @@ class PRUpdateChangelog: "diff": "", # empty diff for initial calculation "changelog_file_str": self.changelog_file_str, "today": date.today(), - "extra_instructions": settings.pr_update_changelog_prompt.extra_instructions, + "extra_instructions": settings.pr_update_changelog.extra_instructions, } self.token_handler = TokenHandler(self.git_provider.pr, self.vars, @@ -96,7 +98,7 @@ class PRUpdateChangelog: if not self.commit_changelog: answer += "\n\n\n>to commit the new content to the CHANGELOG.md file, please type:" \ - "\n>'/update_changelog -commit'\n" + "\n>'/update_changelog --pr_update_changelog.push_changelog_changes=true'\n" if settings.config.verbosity_level >= 2: logging.info(f"answer:\n{answer}") @@ -138,19 +140,6 @@ Example: """ return example_changelog - def _parse_args(self, args, setting): - commit_changelog = False - if args and len(args) >= 1: - try: - if args[0] == "-commit": - commit_changelog = True - except: - pass - else: - commit_changelog = setting.pr_update_changelog.push_changelog_changes - - return commit_changelog - def _get_changlog_file(self): try: self.changelog_file = self.git_provider.repo_obj.get_contents("CHANGELOG.md",