mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 05:10:38 +08:00
Compare commits
17 Commits
v0.9
...
ok/fix_git
Author | SHA1 | Date | |
---|---|---|---|
26d6280a20 | |||
32a19fdab6 | |||
775ccb3f25 | |||
a1c6c57f7b | |||
73bb70fef4 | |||
dcac6c145c | |||
4bda9dfe04 | |||
66644f0224 | |||
e74bb80668 | |||
e06fb534d3 | |||
71a341855e | |||
7d949ad6e2 | |||
4b5f86fcf0 | |||
cd11f51df0 | |||
b40c0b9b23 | |||
816ddeeb9e | |||
11f01a226c |
@ -368,7 +368,7 @@ PYTHONPATH="/PATH/TO/PROJECTS/pr-agent" python pr_agent/cli.py \
|
|||||||
```
|
```
|
||||||
WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
|
WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
|
||||||
```
|
```
|
||||||
3. Follow the instructions to build the Docker image, setup a secrets file and deploy on your own server from [Method 5](#method-5-run-as-a-github-app) steps 4-7.
|
3. Follow the instructions to build the Docker image, setup a secrets file and deploy on your own server from [Method 5](#run-as-a-github-app) steps 4-7.
|
||||||
4. In the secrets file, fill in the following:
|
4. In the secrets file, fill in the following:
|
||||||
- Your OpenAI key.
|
- Your OpenAI key.
|
||||||
- In the [gitlab] section, fill in personal_access_token and shared_secret. The access token can be a personal access token, or a group or project access token.
|
- In the [gitlab] section, fill in personal_access_token and shared_secret. The access token can be a personal access token, or a group or project access token.
|
||||||
|
@ -9,9 +9,10 @@
|
|||||||
### Added::Algo
|
### Added::Algo
|
||||||
- New tool - [generate_labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md)
|
- New tool - [generate_labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md)
|
||||||
- New ability to use [customize labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md#how-to-enable-custom-labels) on the `review` and `describe` tools.
|
- New ability to use [customize labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md#how-to-enable-custom-labels) on the `review` and `describe` tools.
|
||||||
|
- New tool - [add_docs](https://github.com/Codium-ai/pr-agent/blob/main/docs/ADD_DOCUMENTATION.md)
|
||||||
- GitHub Action: Can now use a `.pr_agent.toml` file to control configuration parameters (see [Usage Guide](./Usage.md#working-with-github-action)).
|
- GitHub Action: Can now use a `.pr_agent.toml` file to control configuration parameters (see [Usage Guide](./Usage.md#working-with-github-action)).
|
||||||
- GitHub App: Added ability to trigger tools on [push events](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools-for-new-code-pr-push)
|
- GitHub App: Added ability to trigger tools on [push events](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools-for-new-code-pr-push)
|
||||||
- Support custom domain URLs for azure devops integration (see [link](https://github.com/Codium-ai/pr-agent/pull/381)).
|
- Support custom domain URLs for Azure devops integration (see [link](https://github.com/Codium-ai/pr-agent/pull/381)).
|
||||||
- PR Description default mode is now in [bullet points](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L35).
|
- PR Description default mode is now in [bullet points](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L35).
|
||||||
|
|
||||||
### Added::Documentation
|
### Added::Documentation
|
||||||
|
@ -10,6 +10,7 @@ For example:
|
|||||||
If we wish to add detect changes to SQL queries in a given PR, we can add the following custom label along with its description:
|
If we wish to add detect changes to SQL queries in a given PR, we can add the following custom label along with its description:
|
||||||
|
|
||||||
<kbd><img src=./../pics/custom_labels_list.png width="768"></kbd>
|
<kbd><img src=./../pics/custom_labels_list.png width="768"></kbd>
|
||||||
|
|
||||||
When running the `generate_labels` tool on a PR that includes changes in SQL queries, it will automatically suggest the custom label:
|
When running the `generate_labels` tool on a PR that includes changes in SQL queries, it will automatically suggest the custom label:
|
||||||
<kbd><img src=./../pics/custom_label_published.png width="768"></kbd>
|
<kbd><img src=./../pics/custom_label_published.png width="768"></kbd>
|
||||||
|
|
||||||
|
@ -41,9 +41,10 @@ class BitbucketProvider(GitProvider):
|
|||||||
|
|
||||||
def get_repo_settings(self):
|
def get_repo_settings(self):
|
||||||
try:
|
try:
|
||||||
contents = self.repo_obj.get_contents(
|
url = (f"https://api.bitbucket.org/2.0/repositories/{self.workspace_slug}/{self.repo_slug}/src/"
|
||||||
".pr_agent.toml", ref=self.pr.head.sha
|
f"{self.pr.destination_branch}/.pr_agent.toml")
|
||||||
).decoded_content
|
response = requests.request("GET", url, headers=self.headers)
|
||||||
|
contents = response.text.encode('utf-8')
|
||||||
return contents
|
return contents
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
|
@ -315,7 +315,7 @@ class GitLabProvider(GitProvider):
|
|||||||
|
|
||||||
def get_repo_settings(self):
|
def get_repo_settings(self):
|
||||||
try:
|
try:
|
||||||
contents = self.gl.projects.get(self.id_project).files.get(file_path='.pr_agent.toml', ref=self.mr.source_branch)
|
contents = self.gl.projects.get(self.id_project).files.get(file_path='.pr_agent.toml', ref=self.mr.target_branch).decode()
|
||||||
return contents
|
return contents
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
|
@ -122,7 +122,7 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
if body.get("requested_reviewer", {}).get("login", "") != bot_user:
|
if body.get("requested_reviewer", {}).get("login", "") != bot_user:
|
||||||
return {}
|
return {}
|
||||||
get_logger().info(f"Performing review for {api_url=} because of {event=} and {action=}")
|
get_logger().info(f"Performing review for {api_url=} because of {event=} and {action=}")
|
||||||
await _perform_commands(get_settings().github_app.pr_commands, agent, body, api_url, log_context)
|
await _perform_commands(agent, body, api_url, log_context)
|
||||||
|
|
||||||
# handle pull_request event with synchronize action - "push trigger" for new commits
|
# handle pull_request event with synchronize action - "push trigger" for new commits
|
||||||
elif event == 'pull_request' and action == 'synchronize' and get_settings().github_app.handle_push_trigger:
|
elif event == 'pull_request' and action == 'synchronize' and get_settings().github_app.handle_push_trigger:
|
||||||
@ -174,7 +174,7 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
get_logger().info(f"Skipping incremental review because there was no initial review for {api_url=} yet")
|
get_logger().info(f"Skipping incremental review because there was no initial review for {api_url=} yet")
|
||||||
return {}
|
return {}
|
||||||
get_logger().info(f"Performing incremental review for {api_url=} because of {event=} and {action=}")
|
get_logger().info(f"Performing incremental review for {api_url=} because of {event=} and {action=}")
|
||||||
await _perform_commands(get_settings().github_app.push_commands, agent, body, api_url, log_context)
|
await _perform_commands(agent, body, api_url, log_context)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
# release the waiting task block
|
# release the waiting task block
|
||||||
@ -203,8 +203,9 @@ def _check_pull_request_event(action: str, body: dict, log_context: dict, bot_us
|
|||||||
return pull_request, api_url
|
return pull_request, api_url
|
||||||
|
|
||||||
|
|
||||||
async def _perform_commands(commands: List[str], agent: PRAgent, body: dict, api_url: str, log_context: dict):
|
async def _perform_commands(agent: PRAgent, body: dict, api_url: str, log_context: dict):
|
||||||
apply_repo_settings(api_url)
|
apply_repo_settings(api_url)
|
||||||
|
commands = get_settings().github_app.pr_commands
|
||||||
for command in commands:
|
for command in commands:
|
||||||
split_command = command.split(" ")
|
split_command = command.split(" ")
|
||||||
command = split_command[0]
|
command = split_command[0]
|
||||||
|
@ -58,13 +58,13 @@ async def gitlab_webhook(background_tasks: BackgroundTasks, request: Request):
|
|||||||
if data.get('object_kind') == 'merge_request' and data['object_attributes'].get('action') in ['open', 'reopen']:
|
if data.get('object_kind') == 'merge_request' and data['object_attributes'].get('action') in ['open', 'reopen']:
|
||||||
get_logger().info(f"A merge request has been opened: {data['object_attributes'].get('title')}")
|
get_logger().info(f"A merge request has been opened: {data['object_attributes'].get('title')}")
|
||||||
url = data['object_attributes'].get('url')
|
url = data['object_attributes'].get('url')
|
||||||
handle_request(background_tasks, url, "/review")
|
handle_request(background_tasks, url, "/review", log_context)
|
||||||
elif data.get('object_kind') == 'note' and data['event_type'] == 'note':
|
elif data.get('object_kind') == 'note' and data['event_type'] == 'note':
|
||||||
if 'merge_request' in data:
|
if 'merge_request' in data:
|
||||||
mr = data['merge_request']
|
mr = data['merge_request']
|
||||||
url = mr.get('url')
|
url = mr.get('url')
|
||||||
body = data.get('object_attributes', {}).get('note')
|
body = data.get('object_attributes', {}).get('note')
|
||||||
handle_request(background_tasks, url, body)
|
handle_request(background_tasks, url, body, log_context)
|
||||||
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,9 +116,9 @@ class PRReviewer:
|
|||||||
|
|
||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
get_logger().info('Pushing PR review...')
|
get_logger().info('Pushing PR review...')
|
||||||
|
previous_review_comment = self._get_previous_review_comment()
|
||||||
self.git_provider.publish_comment(pr_comment)
|
self.git_provider.publish_comment(pr_comment)
|
||||||
self.git_provider.remove_initial_comment()
|
self.git_provider.remove_initial_comment()
|
||||||
previous_review_comment = self._get_previous_review_comment()
|
|
||||||
if previous_review_comment:
|
if previous_review_comment:
|
||||||
self._remove_previous_review_comment(previous_review_comment)
|
self._remove_previous_review_comment(previous_review_comment)
|
||||||
if get_settings().pr_reviewer.inline_code_comments:
|
if get_settings().pr_reviewer.inline_code_comments:
|
||||||
|
Reference in New Issue
Block a user