From 7b6a6c71644cba2eff09b54ffd2998ee4ac8a602 Mon Sep 17 00:00:00 2001 From: Zohar Meir <33152084+zmeir@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:05:13 +0200 Subject: [PATCH 1/7] Fix formatting when last commit message contains _ --- pr_agent/tools/pr_reviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index fdb7161e..7ec9d5ad 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -239,7 +239,7 @@ class PRReviewer: last_commit_msg = self.incremental.commits_range[0].commit.message if self.incremental.commits_range else "" incremental_review_markdown_text = f"Starting from commit {last_commit_url}" if last_commit_msg: - incremental_review_markdown_text += f" \n_({last_commit_msg.splitlines(keepends=False)[0]})_" + incremental_review_markdown_text += f" \n_({last_commit_msg.splitlines(keepends=False)[0].replace('_', r'\_')})_" data = OrderedDict(data) data.update({'Incremental PR Review': { "⏮️ Review for commits since previous PR-Agent review": incremental_review_markdown_text}}) From 29a8cf8357908f1528106a01ae71e5baeb772665 Mon Sep 17 00:00:00 2001 From: KennyDizi Date: Tue, 31 Oct 2023 20:38:27 +0700 Subject: [PATCH 2/7] fix typo for ollama --- pr_agent/settings/.secrets_template.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/settings/.secrets_template.toml b/pr_agent/settings/.secrets_template.toml index 0271a2c3..b6b11cd4 100644 --- a/pr_agent/settings/.secrets_template.toml +++ b/pr_agent/settings/.secrets_template.toml @@ -34,7 +34,7 @@ key = "" # Optional, uncomment if you want to use Huggingface Inference API. Acq api_base = "" # the base url for your huggingface inference endpoint [ollama] -api_base = "" # the base url for your huggingface inference endpoint +api_base = "" # the base url for your local Llama 2, Code Llama, and other models inference endpoint. Acquire through https://ollama.ai/ [github] # ---- Set the following only for deployment type == "user" From ad1c51c5363837b945e674da42ad57ce0f4b6521 Mon Sep 17 00:00:00 2001 From: KennyDizi Date: Wed, 1 Nov 2023 19:06:29 +0700 Subject: [PATCH 3/7] Fix SyntaxError: f-string expression part cannot include a backslash --- pr_agent/tools/pr_reviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 7ec9d5ad..c2892150 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -239,7 +239,7 @@ class PRReviewer: last_commit_msg = self.incremental.commits_range[0].commit.message if self.incremental.commits_range else "" incremental_review_markdown_text = f"Starting from commit {last_commit_url}" if last_commit_msg: - incremental_review_markdown_text += f" \n_({last_commit_msg.splitlines(keepends=False)[0].replace('_', r'\_')})_" + incremental_review_markdown_text += f" \n_({last_commit_msg.splitlines(keepends=False)[0].replace('__', '__')})_" data = OrderedDict(data) data.update({'Incremental PR Review': { "⏮️ Review for commits since previous PR-Agent review": incremental_review_markdown_text}}) From 9fbf89670dfce25eb65597966f9c8d7f92a86677 Mon Sep 17 00:00:00 2001 From: KennyDizi Date: Wed, 1 Nov 2023 19:11:52 +0700 Subject: [PATCH 4/7] Improve expression portion of f-strings --- pr_agent/tools/pr_reviewer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index c2892150..7cf561e2 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -239,7 +239,8 @@ class PRReviewer: last_commit_msg = self.incremental.commits_range[0].commit.message if self.incremental.commits_range else "" incremental_review_markdown_text = f"Starting from commit {last_commit_url}" if last_commit_msg: - incremental_review_markdown_text += f" \n_({last_commit_msg.splitlines(keepends=False)[0].replace('__', '__')})_" + replacement = last_commit_msg.splitlines(keepends=False)[0].replace('_', r'\_') + incremental_review_markdown_text += f" \n_({replacement})_" data = OrderedDict(data) data.update({'Incremental PR Review': { "⏮️ Review for commits since previous PR-Agent review": incremental_review_markdown_text}}) From 6666a128eef5839859037f894e68d531ceee7d28 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 1 Nov 2023 18:36:12 +0200 Subject: [PATCH 5/7] Update Usage.md --- Usage.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Usage.md b/Usage.md index 2548431f..9aa20482 100644 --- a/Usage.md +++ b/Usage.md @@ -108,12 +108,22 @@ Any configuration value in [configuration file](pr_agent/settings/configuration. ### Working with GitHub App -When running PR-Agent from [GitHub App](INSTALL.md#method-5-run-as-a-github-app), the default configurations from a pre-built docker will be initially loaded. +When running PR-Agent from GitHub App, the default [configuration file](pr_agent/settings/configuration.toml) from a pre-built docker will be initially loaded. + +By uploading a local `.pr_agent.toml` file, you can edit and customize any configuration parameter. + +For example, if you set in `.pr_agent.toml`: + +``` +[pr_reviewer] +num_code_suggestions=1 +``` + +Than you will overwrite the default number of code suggestions to be 1. #### GitHub app automatic tools -The [github_app](pr_agent/settings/configuration.toml#L56) section defines GitHub app specific configurations. +The [github_app](pr_agent/settings/configuration.toml#L76) section defines GitHub app-specific configurations. In this section you can define configurations to control the conditions for which tools will **run automatically**. -Note that a local `.pr_agent.toml` file enables you to edit and customize the default parameters of any tool, not just the ones that are run automatically. ##### GitHub app automatic tools for PR actions The GitHub app can respond to the following actions on a PR: @@ -151,7 +161,7 @@ handle_pr_actions = [] ``` ##### GitHub app automatic tools for new code (PR push) -In addition the running automatic tools when a PR is opened, the GitHub app can also respond to new code that is pushed to an open PR. +In addition to running automatic tools when a PR is opened, the GitHub app can also respond to new code that is pushed to an open PR. The configuration toggle `handle_push_trigger` can be used to enable this feature. The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the PR. From 15573e228686b0ec4674704d1ded30df6a5c83a5 Mon Sep 17 00:00:00 2001 From: Zohar Meir <33152084+zmeir@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:10:54 +0200 Subject: [PATCH 6/7] Fix error in `get_main_pr_languages` when the diff is empty This can happen for example when you have one commit add a line to a file and the next commit deletes that line. Then if those are the only 2 commits in the PR the diff will be empty. --- pr_agent/git_providers/git_provider.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index 6f986cf0..9dee9e3c 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -143,6 +143,9 @@ def get_main_pr_language(languages, files) -> str: if not languages: get_logger().info("No languages detected") return main_language_str + if not files: + get_logger().info("No files in diff") + return main_language_str try: top_language = max(languages, key=languages.get).lower() From 3ddc7e79d1424fc24d37226abcacd8e0e696f08b Mon Sep 17 00:00:00 2001 From: Hussam Lawen Date: Thu, 2 Nov 2023 11:45:34 +0200 Subject: [PATCH 7/7] Update pr_reviewer_prompts.toml --- pr_agent/settings/pr_reviewer_prompts.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index b717ec3d..556d824e 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -151,7 +151,7 @@ PR Analysis: PR summary: |- xxx Type of PR: |- - Bug fix + ... {%- if require_score %} Score: 89 {%- endif %}