mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-14 17:50:37 +08:00
Merge pull request #744 from Codium-ai/tr/final_update_message
Add 'final_update_message' option to control publishing of update messages
This commit is contained in:
8
Usage.md
8
Usage.md
@ -4,7 +4,7 @@
|
|||||||
- [Introduction](#introduction)
|
- [Introduction](#introduction)
|
||||||
- [Configuration Options](#configuration-options)
|
- [Configuration Options](#configuration-options)
|
||||||
- [Managing Mail Notifications](#managing-mail-notifications)
|
- [Managing Mail Notifications](#managing-mail-notifications)
|
||||||
- [Automation and Usage](#usage-types)
|
- [Usage and Automation](#usage-and-automation)
|
||||||
- [Local Repo (CLI)](#working-from-a-local-repo-cli)
|
- [Local Repo (CLI)](#working-from-a-local-repo-cli)
|
||||||
- [Online Usage](#online-usage)
|
- [Online Usage](#online-usage)
|
||||||
- [GitHub App](#working-with-github-app)
|
- [GitHub App](#working-with-github-app)
|
||||||
@ -109,7 +109,7 @@ https://www.quora.com/How-can-you-filter-emails-for-specific-people-in-Gmail#:~:
|
|||||||
|
|
||||||
<kbd><img src="https://codium.ai/images/pr_agent/filter_mail_notifications.png" width="512"></kbd>
|
<kbd><img src="https://codium.ai/images/pr_agent/filter_mail_notifications.png" width="512"></kbd>
|
||||||
|
|
||||||
## Usage Types
|
## Usage and Automation
|
||||||
|
|
||||||
### Working from a local repo (CLI)
|
### Working from a local repo (CLI)
|
||||||
When running from your local repo (CLI), your local configuration file will be used.
|
When running from your local repo (CLI), your local configuration file will be used.
|
||||||
@ -211,8 +211,8 @@ The configuration parameter `push_commands` defines the list of tools that will
|
|||||||
[github_app]
|
[github_app]
|
||||||
handle_push_trigger = true
|
handle_push_trigger = true
|
||||||
push_commands = [
|
push_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true --pr_description.final_update_message=false",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false",
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and `review` tools, with the specified parameters.
|
This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and `review` tools, with the specified parameters.
|
||||||
|
@ -38,6 +38,8 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L19) related
|
|||||||
- `inline_code_comments`: if set to true, the tool will publish the code suggestions as comments on the code diff. Default is false.
|
- `inline_code_comments`: if set to true, the tool will publish the code suggestions as comments on the code diff. Default is false.
|
||||||
- `persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true.
|
- `persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true.
|
||||||
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
||||||
|
- `final_update_message`: if set to true, it will add a comment message after finishing calling `/review`, if a message already exits. Default is true.
|
||||||
|
|
||||||
#### Enable\\disable features
|
#### Enable\\disable features
|
||||||
- `require_focused_review`: if set to true, the tool will add a section - 'is the PR a focused one'. Default is false.
|
- `require_focused_review`: if set to true, the tool will add a section - 'is the PR a focused one'. Default is false.
|
||||||
- `require_score_review`: if set to true, the tool will add a section that scores the PR. Default is false.
|
- `require_score_review`: if set to true, the tool will add a section that scores the PR. Default is false.
|
||||||
|
@ -160,7 +160,11 @@ class BitbucketProvider(GitProvider):
|
|||||||
def get_comment_url(self, comment):
|
def get_comment_url(self, comment):
|
||||||
return comment.data['links']['html']['href']
|
return comment.data['links']['html']['href']
|
||||||
|
|
||||||
def publish_persistent_comment(self, pr_comment: str, initial_header: str, update_header: bool = True, name='review'):
|
def publish_persistent_comment(self, pr_comment: str,
|
||||||
|
initial_header: str,
|
||||||
|
update_header: bool = True,
|
||||||
|
name='review',
|
||||||
|
final_update_message=True):
|
||||||
try:
|
try:
|
||||||
for comment in self.pr.comments():
|
for comment in self.pr.comments():
|
||||||
body = comment.raw
|
body = comment.raw
|
||||||
@ -175,6 +179,7 @@ class BitbucketProvider(GitProvider):
|
|||||||
get_logger().info(f"Persistent mode - updating comment {comment_url} to latest {name} message")
|
get_logger().info(f"Persistent mode - updating comment {comment_url} to latest {name} message")
|
||||||
d = {"content": {"raw": pr_comment_updated}}
|
d = {"content": {"raw": pr_comment_updated}}
|
||||||
response = comment._update_data(comment.put(None, data=d))
|
response = comment._update_data(comment.put(None, data=d))
|
||||||
|
if final_update_message:
|
||||||
self.publish_comment(
|
self.publish_comment(
|
||||||
f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}")
|
f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}")
|
||||||
return
|
return
|
||||||
|
@ -124,7 +124,11 @@ class GitProvider(ABC):
|
|||||||
def publish_comment(self, pr_comment: str, is_temporary: bool = False):
|
def publish_comment(self, pr_comment: str, is_temporary: bool = False):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def publish_persistent_comment(self, pr_comment: str, initial_header: str, update_header: bool, name='review'):
|
def publish_persistent_comment(self, pr_comment: str,
|
||||||
|
initial_header: str,
|
||||||
|
update_header: bool = True,
|
||||||
|
name='review',
|
||||||
|
final_update_message=True):
|
||||||
self.publish_comment(pr_comment)
|
self.publish_comment(pr_comment)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
@ -197,7 +197,11 @@ class GithubProvider(GitProvider):
|
|||||||
def get_comment_url(self, comment) -> str:
|
def get_comment_url(self, comment) -> str:
|
||||||
return comment.html_url
|
return comment.html_url
|
||||||
|
|
||||||
def publish_persistent_comment(self, pr_comment: str, initial_header: str, update_header: bool = True, name='review'):
|
def publish_persistent_comment(self, pr_comment: str,
|
||||||
|
initial_header: str,
|
||||||
|
update_header: bool = True,
|
||||||
|
name='review',
|
||||||
|
final_update_message=True):
|
||||||
prev_comments = list(self.pr.get_issue_comments())
|
prev_comments = list(self.pr.get_issue_comments())
|
||||||
for comment in prev_comments:
|
for comment in prev_comments:
|
||||||
body = comment.body
|
body = comment.body
|
||||||
@ -211,6 +215,7 @@ class GithubProvider(GitProvider):
|
|||||||
pr_comment_updated = pr_comment
|
pr_comment_updated = pr_comment
|
||||||
get_logger().info(f"Persistent mode- updating comment {comment_url} to latest review message")
|
get_logger().info(f"Persistent mode- updating comment {comment_url} to latest review message")
|
||||||
response = comment.edit(pr_comment_updated)
|
response = comment.edit(pr_comment_updated)
|
||||||
|
if final_update_message:
|
||||||
self.publish_comment(
|
self.publish_comment(
|
||||||
f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}")
|
f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}")
|
||||||
return
|
return
|
||||||
|
@ -151,7 +151,11 @@ class GitLabProvider(GitProvider):
|
|||||||
def get_comment_url(self, comment):
|
def get_comment_url(self, comment):
|
||||||
return f"{self.mr.web_url}#note_{comment.id}"
|
return f"{self.mr.web_url}#note_{comment.id}"
|
||||||
|
|
||||||
def publish_persistent_comment(self, pr_comment: str, initial_header: str, update_header: bool = True, name='review'):
|
def publish_persistent_comment(self, pr_comment: str,
|
||||||
|
initial_header: str,
|
||||||
|
update_header: bool = True,
|
||||||
|
name='review',
|
||||||
|
final_update_message=True):
|
||||||
try:
|
try:
|
||||||
for comment in self.mr.notes.list(get_all=True)[::-1]:
|
for comment in self.mr.notes.list(get_all=True)[::-1]:
|
||||||
if comment.body.startswith(initial_header):
|
if comment.body.startswith(initial_header):
|
||||||
@ -164,6 +168,7 @@ class GitLabProvider(GitProvider):
|
|||||||
pr_comment_updated = pr_comment
|
pr_comment_updated = pr_comment
|
||||||
get_logger().info(f"Persistent mode - updating comment {comment_url} to latest {name} message")
|
get_logger().info(f"Persistent mode - updating comment {comment_url} to latest {name} message")
|
||||||
response = self.mr.notes.update(comment.id, {'body': pr_comment_updated})
|
response = self.mr.notes.update(comment.id, {'body': pr_comment_updated})
|
||||||
|
if final_update_message:
|
||||||
self.publish_comment(
|
self.publish_comment(
|
||||||
f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}")
|
f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}")
|
||||||
return
|
return
|
||||||
|
@ -36,6 +36,7 @@ ask_and_reflect=false
|
|||||||
#automatic_review=true
|
#automatic_review=true
|
||||||
persistent_comment=true
|
persistent_comment=true
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
|
final_update_message = true
|
||||||
# review labels
|
# review labels
|
||||||
enable_review_labels_security=true
|
enable_review_labels_security=true
|
||||||
enable_review_labels_effort=true
|
enable_review_labels_effort=true
|
||||||
|
@ -87,9 +87,14 @@ class PRCodeSuggestions:
|
|||||||
else:
|
else:
|
||||||
data = await retry_with_fallback_models(self._prepare_prediction_extended, ModelType.TURBO)
|
data = await retry_with_fallback_models(self._prepare_prediction_extended, ModelType.TURBO)
|
||||||
|
|
||||||
|
if (not data) or (not 'code_suggestions' in data) or (not data['code_suggestions']):
|
||||||
if (not data) or (not 'code_suggestions' in data):
|
get_logger().error('No code suggestions found for PR.')
|
||||||
get_logger().info('No code suggestions found for PR.')
|
pr_body = "## PR Code Suggestions\n\nNo code suggestions found for PR."
|
||||||
|
get_logger().debug(f"PR output", artifact=pr_body)
|
||||||
|
if self.progress_response:
|
||||||
|
self.git_provider.edit_comment(self.progress_response, body=pr_body)
|
||||||
|
else:
|
||||||
|
self.git_provider.publish_comment(pr_body)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (not self.is_extended and get_settings().pr_code_suggestions.rank_suggestions) or \
|
if (not self.is_extended and get_settings().pr_code_suggestions.rank_suggestions) or \
|
||||||
@ -317,7 +322,7 @@ class PRCodeSuggestions:
|
|||||||
suggestion_list.append(suggestion)
|
suggestion_list.append(suggestion)
|
||||||
data_sorted = [[]] * len(suggestion_list)
|
data_sorted = [[]] * len(suggestion_list)
|
||||||
|
|
||||||
if len(suggestion_list ) == 1:
|
if len(suggestion_list) == 1:
|
||||||
return suggestion_list
|
return suggestion_list
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -121,9 +121,11 @@ class PRReviewer:
|
|||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
# publish the review
|
# publish the review
|
||||||
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
|
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
|
||||||
|
final_update_message = get_settings().pr_reviewer.final_update_message
|
||||||
self.git_provider.publish_persistent_comment(pr_review,
|
self.git_provider.publish_persistent_comment(pr_review,
|
||||||
initial_header="## PR Review",
|
initial_header="## PR Review",
|
||||||
update_header=True)
|
update_header=True,
|
||||||
|
final_update_message=final_update_message, )
|
||||||
else:
|
else:
|
||||||
self.git_provider.publish_comment(pr_review)
|
self.git_provider.publish_comment(pr_review)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user