feat: Add configuration for inline PR review activation
- Introduced `read_review_inline_config` to enable inline code comments based on config - Added new configuration file `command.py` to manage PR review inline settings - Updated `command.py` to conditionally set inline code comments based on new config
This commit is contained in:
parent
fa308c36ab
commit
5595097aed
@ -102,6 +102,7 @@ from merico.pr.config_util import (
|
||||
get_gitlab_host,
|
||||
get_repo_type,
|
||||
read_server_access_token_with_input,
|
||||
read_review_inline_config,
|
||||
)
|
||||
from merico.pr.custom_suggestions_config import get_custom_suggestions_system_prompt
|
||||
|
||||
@ -169,7 +170,8 @@ language_prompt = "\n\n输出内容使用中文输出。\n" if language == "zh"
|
||||
get_settings().pr_code_suggestions_prompt.system += language_prompt
|
||||
get_settings().pr_review_prompt.system += language_prompt
|
||||
get_settings().pr_description_prompt.system += language_prompt
|
||||
# get_settings().pr_reviewer.inline_code_comments = True
|
||||
if read_review_inline_config():
|
||||
get_settings().pr_reviewer.inline_code_comments = True
|
||||
|
||||
# config for find similar issues
|
||||
get_settings().set("PR_SIMILAR_ISSUE.VECTORDB", "lancedb")
|
||||
|
67
merico/pr/config/command.py
Normal file
67
merico/pr/config/command.py
Normal file
@ -0,0 +1,67 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from lib.chatmark import Checkbox
|
||||
|
||||
|
||||
# Configuration items
|
||||
CONFIG_ITEMS = {
|
||||
"pr_review_inline": "PR Review Inline Enabled",
|
||||
}
|
||||
|
||||
# Configuration file paths
|
||||
GLOBAL_CONFIG_PATH = os.path.join(os.path.expanduser("~"), ".chat", ".workflow_config.json")
|
||||
|
||||
def read_config(config_path, item):
|
||||
if os.path.exists(config_path):
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
return config.get(item)
|
||||
return None
|
||||
|
||||
def save_config(config_path, item, value):
|
||||
if os.path.exists(config_path):
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
else:
|
||||
config = {}
|
||||
|
||||
config[item] = value
|
||||
with open(config_path, "w", encoding="utf-8") as f:
|
||||
json.dump(config, f, indent=4)
|
||||
|
||||
|
||||
def is_pre_review_inline_enabled(current_value=False):
|
||||
print("\n\nEnable PR Review Inline:\n\n")
|
||||
checkbox = Checkbox(
|
||||
[
|
||||
"PR Review Inline Enabled",
|
||||
],
|
||||
[current_value],
|
||||
)
|
||||
checkbox.render()
|
||||
|
||||
print(f"\n\ncheckbox.selections: {checkbox.selections}\n\n")
|
||||
if len(checkbox.selections) > 0:
|
||||
return True
|
||||
if checkbox.selections is None:
|
||||
return None
|
||||
return False
|
||||
|
||||
def main():
|
||||
print("Starting configuration of workflow settings...", end="\n\n", flush=True)
|
||||
print("If you want to change access token or host url, "
|
||||
"please edit the configuration file directly.")
|
||||
print("Configuration file is located at:", GLOBAL_CONFIG_PATH, end="\n\n", flush=True)
|
||||
|
||||
pr_review_inline_enable = read_config(GLOBAL_CONFIG_PATH, "pr_review_inline")
|
||||
|
||||
pr_review_inline_enable = is_pre_review_inline_enabled(pr_review_inline_enable or False)
|
||||
if pr_review_inline_enable is not None:
|
||||
save_config(GLOBAL_CONFIG_PATH, "pr_review_inline", pr_review_inline_enable)
|
||||
print("Workflow settings configuration successful.")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
3
merico/pr/config/command.yml
Normal file
3
merico/pr/config/command.yml
Normal file
@ -0,0 +1,3 @@
|
||||
description: 'Config required settings for GIT workflows.'
|
||||
steps:
|
||||
- run: $devchat_python $command_path/command.py
|
@ -114,6 +114,14 @@ def read_gitlab_host():
|
||||
return config_data["gitlab_host"]
|
||||
return ""
|
||||
|
||||
def read_review_inline_config():
|
||||
config_path = os.path.join(os.path.expanduser("~/.chat"), ".workflow_config.json")
|
||||
if os.path.exists(config_path):
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
config_data = json.load(f)
|
||||
if "pr_review_inline" in config_data:
|
||||
return config_data["pr_review_inline"]
|
||||
return False
|
||||
|
||||
def save_github_token(github_token):
|
||||
config_path = os.path.join(os.path.expanduser("~/.chat"), ".workflow_config.json")
|
||||
|
Loading…
x
Reference in New Issue
Block a user