Skip to content

Commit

Permalink
Merge pull request qodo-ai#499 from Codium-ai/tr/describe_message
Browse files Browse the repository at this point in the history
final update message in PR description
  • Loading branch information
mrT23 authored Dec 3, 2023
2 parents c21e606 + fe7d2bb commit c9debc3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/DESCRIBE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Under the section 'pr_description', the [configuration file](./../pr_agent/setti
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
- To enable `custom labels`, apply the configuration changes described [here](./GENERATE_CUSTOM_LABELS.md#configuration-changes)
- `enable_pr_type`: if set to false, it will not show the `PR type` as a text value in the description content. Default is true.
- `final_update_message`: if set to true, it will add a comment message [`PR Description updated to latest commit...`](https://github.com/Codium-ai/pr-agent/pull/499#issuecomment-1837412176) after finishing calling `/describe`. Default is true.

### Markers template

Expand Down
1 change: 1 addition & 0 deletions pr_agent/git_providers/codecommit_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self, pr_url: Optional[str] = None, incremental: Optional[bool] = F
self.pr = None
self.diff_files = None
self.git_files = None
self.pr_url = pr_url
if pr_url:
self.set_pr(pr_url)

Expand Down
2 changes: 1 addition & 1 deletion pr_agent/git_providers/gerrit_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __init__(self, key: str, incremental=False):
)
self.repo = Repo(self.repo_path)
assert self.repo

self.pr_url = base_url
self.pr = PullRequestMimic(self.get_pr_title(), self.get_diff_files())

def get_pr_title(self):
Expand Down
1 change: 1 addition & 0 deletions pr_agent/git_providers/github_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, pr_url: Optional[str] = None, incremental=IncrementalPR(False
self.diff_files = None
self.git_files = None
self.incremental = incremental
self.pr_url = pr_url
if pr_url and 'pull' in pr_url:
self.set_pr(pr_url)
self.last_commit_id = list(self.pr.get_commits())[-1]
Expand Down
1 change: 1 addition & 0 deletions pr_agent/git_providers/gitlab_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, merge_request_url: Optional[str] = None, incremental: Optiona
self.diff_files = None
self.git_files = None
self.temp_comments = []
self.pr_url = merge_request_url
self._set_merge_request(merge_request_url)
self.RE_HUNK_HEADER = re.compile(
r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@[ ]?(.*)")
Expand Down
1 change: 1 addition & 0 deletions pr_agent/settings/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ keep_original_user_title=false
use_bullet_points=true
extra_instructions = ""
enable_pr_type=true
final_update_message = true

# markers
use_description_markers=false
Expand Down
8 changes: 7 additions & 1 deletion pr_agent/tools/pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ async def run(self):
if get_settings().pr_description.publish_labels and self.git_provider.is_supported("get_labels"):
current_labels = self.git_provider.get_labels()
user_labels = get_user_labels(current_labels)

self.git_provider.publish_labels(pr_labels + user_labels)

if (get_settings().pr_description.final_update_message and
hasattr(self.git_provider, 'pr_url') and self.git_provider.pr_url):
latest_commit_url = self.git_provider.get_latest_commit_url()
if latest_commit_url:
self.git_provider.publish_comment(
f"**[PR Description]({self.git_provider.pr_url})** updated to latest commit ({latest_commit_url})")
self.git_provider.remove_initial_comment()
except Exception as e:
get_logger().error(f"Error generating PR description {self.pr_id}: {e}")
Expand Down

0 comments on commit c9debc3

Please sign in to comment.