mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
final
This commit is contained in:
@ -1,12 +1,9 @@
|
||||
[pr_update_changelog_prompt]
|
||||
system="""You are a language model called CodiumAI-PR-Code-Reviewer.
|
||||
Your task is to update the CHANGELOG.md file of the project, to reflect the changes in this PR.
|
||||
The updated content should be short and concise as possible.
|
||||
It 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 content that is not already in the CHANGELOG.md file.
|
||||
|
||||
system="""You are a language model called CodiumAI-PR-Changlog-summarizer.
|
||||
Your task is to update the CHANGELOG.md file of the project, to shortly summarize important changes introduced in this PR (the '+' lines).
|
||||
- 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 generic and avoid specific details. The output should be minimal, no more than 3-4 short lines. Ignore non-relevant subsections.
|
||||
"""
|
||||
|
||||
user="""PR Info:
|
||||
@ -30,7 +27,7 @@ Current date:
|
||||
|
||||
The current CHANGELOG.md:
|
||||
```
|
||||
{{changelog_file_str}}
|
||||
{{ changelog_file_str }}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
@ -30,14 +30,15 @@ class PRUpdateChangelog:
|
||||
changelog_file_lines = changelog_file_lines[:CHANGELOG_LINES]
|
||||
self.changelog_file_str = "\n".join(changelog_file_lines)
|
||||
except:
|
||||
if settings.pr_update_changelog.push_changelog_changes:
|
||||
self.changelog_file_str = ""
|
||||
if settings.config.publish_output and settings.pr_update_changelog.push_changelog_changes:
|
||||
logging.info("No CHANGELOG.md file found in the repository. Creating one...")
|
||||
changelog_file = self.git_provider.repo_obj.create_file(path="CHANGELOG.md",
|
||||
message='add CHANGELOG.md',
|
||||
content="",
|
||||
branch=self.git_provider.get_pr_branch())
|
||||
self.changelog_file = changelog_file['content']
|
||||
self.changelog_file_str = ""
|
||||
|
||||
if not self.changelog_file_str:
|
||||
self.changelog_file_str = self._get_default_changelog()
|
||||
|
||||
@ -84,12 +85,7 @@ class PRUpdateChangelog:
|
||||
|
||||
async def _prepare_prediction(self, model: str):
|
||||
logging.info('Getting PR diff...')
|
||||
# we are using extended hunk with line numbers for code suggestions
|
||||
self.patches_diff = get_pr_diff(self.git_provider,
|
||||
self.token_handler,
|
||||
model,
|
||||
add_line_numbers_to_hunks=True,
|
||||
disable_extra_lines=True)
|
||||
self.patches_diff = get_pr_diff(self.git_provider, self.token_handler, model)
|
||||
logging.info('Getting AI prediction...')
|
||||
self.prediction = await self._get_prediction(model)
|
||||
|
||||
@ -109,7 +105,10 @@ class PRUpdateChangelog:
|
||||
|
||||
def _prepare_changelog_update(self) -> Tuple[str, str]:
|
||||
answer = self.prediction.strip().strip("```").strip()
|
||||
existing_content = self.changelog_file.decoded_content.decode()
|
||||
if hasattr(self, "changelog_file"):
|
||||
existing_content = self.changelog_file.decoded_content.decode()
|
||||
else:
|
||||
existing_content = ""
|
||||
if existing_content:
|
||||
new_file_content = answer + "\n\n" + self.changelog_file.decoded_content.decode()
|
||||
else:
|
||||
|
Reference in New Issue
Block a user