Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
mrT23 committed Jul 30, 2023
1 parent 129b7a6 commit 051af41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pr_agent/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"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"
]]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 5 additions & 16 deletions pr_agent/tools/pr_update_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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

Expand All @@ -23,7 +24,8 @@ def __init__(self, pr_url: str, cli_mode=False, args=None):
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
Expand All @@ -37,7 +39,7 @@ def __init__(self, pr_url: str, cli_mode=False, args=None):
"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,
Expand Down Expand Up @@ -96,7 +98,7 @@ def _prepare_changelog_update(self) -> Tuple[str, str]:

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}")
Expand Down Expand Up @@ -138,19 +140,6 @@ def _get_default_changelog(self):
"""
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",
Expand Down

0 comments on commit 051af41

Please sign in to comment.