Skip to content

Commit b952808

Browse files
BigOrangeQWQhe0119
andauthored
chore: 更新 issue template 里的参数 (#400)
Co-authored-by: uy/sun <[email protected]>
1 parent 6939a1f commit b952808

File tree

14 files changed

+472
-67
lines changed

14 files changed

+472
-67
lines changed

src/plugins/github/plugins/config/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from src.plugins.github.handlers import GitHandler, IssueHandler
66
from src.plugins.github.plugins.publish.constants import (
77
PLUGIN_CONFIG_PATTERN,
8+
PLUGIN_MODULE_IMPORT_PATTERN,
89
PLUGIN_MODULE_NAME_PATTERN,
910
PROJECT_LINK_PATTERN,
1011
)
@@ -26,7 +27,7 @@ async def validate_info_from_issue(handler: IssueHandler) -> ValidationDict:
2627
# 从议题里提取插件所需信息
2728
raw_data: dict[str, Any] = extract_issue_info_from_issue(
2829
{
29-
"module_name": PLUGIN_MODULE_NAME_PATTERN,
30+
"module_name": [PLUGIN_MODULE_NAME_PATTERN, PLUGIN_MODULE_IMPORT_PATTERN],
3031
"project_link": PROJECT_LINK_PATTERN,
3132
"test_config": PLUGIN_CONFIG_PATTERN,
3233
},

src/plugins/github/plugins/publish/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
BOT_DESC_PATTERN = re.compile(ISSUE_PATTERN.format("机器人描述"))
1515
BOT_HOMEPAGE_PATTERN = re.compile(ISSUE_PATTERN.format("机器人项目仓库/主页链接"))
1616
# 插件
17-
PLUGIN_MODULE_NAME_PATTERN = re.compile(ISSUE_PATTERN.format("插件 import 包名"))
17+
PLUGIN_MODULE_NAME_PATTERN = re.compile(ISSUE_PATTERN.format("插件模块名"))
18+
PLUGIN_MODULE_IMPORT_PATTERN = re.compile(ISSUE_PATTERN.format("插件 import 包名"))
1819
PLUGIN_NAME_STRING = "插件名称"
20+
1921
PLUGIN_NAME_PATTERN = re.compile(ISSUE_PATTERN.format(PLUGIN_NAME_STRING))
2022
PLUGIN_DESC_STRING = "插件描述"
2123
PLUGIN_DESC_PATTERN = re.compile(ISSUE_PATTERN.format(PLUGIN_DESC_STRING))

src/plugins/github/plugins/publish/validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
PLUGIN_CONFIG_PATTERN,
2424
PLUGIN_DESC_PATTERN,
2525
PLUGIN_HOMEPAGE_PATTERN,
26+
PLUGIN_MODULE_IMPORT_PATTERN,
2627
PLUGIN_MODULE_NAME_PATTERN,
2728
PLUGIN_NAME_PATTERN,
2829
PLUGIN_SUPPORTED_ADAPTERS_PATTERN,
@@ -58,7 +59,7 @@ async def validate_plugin_info_from_issue(
5859
# 从议题里提取插件所需信息
5960
raw_data: dict[str, Any] = extract_issue_info_from_issue(
6061
{
61-
"module_name": PLUGIN_MODULE_NAME_PATTERN,
62+
"module_name": [PLUGIN_MODULE_NAME_PATTERN, PLUGIN_MODULE_IMPORT_PATTERN],
6263
"project_link": PROJECT_LINK_PATTERN,
6364
"test_config": PLUGIN_CONFIG_PATTERN,
6465
"tags": TAGS_PATTERN,

src/plugins/github/plugins/remove/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
REMOVE_BOT_NAME_PATTERN = re.compile(ISSUE_PATTERN.format("机器人名称"))
1010
# Plugin
1111
REMOVE_PLUGIN_PROJECT_LINK_PATTERN = re.compile(ISSUE_PATTERN.format("PyPI 项目名"))
12-
REMOVE_PLUGIN_MODULE_NAME_PATTERN = re.compile(ISSUE_PATTERN.format("import 包名"))
12+
REMOVE_PLUGIN_IMPORT_NAME_PATTERN = re.compile(ISSUE_PATTERN.format("import 包名"))
13+
REMOVE_PLUGIN_MODULE_NAME_PATTERN = re.compile(ISSUE_PATTERN.format("插件模块名"))
14+
1315
# Driver / Adapter
1416
REMOVE_HOMEPAGE_PATTERN = re.compile(ISSUE_PATTERN.format("项目主页"))
1517

src/plugins/github/plugins/remove/validation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .constants import (
1313
REMOVE_BOT_HOMEPAGE_PATTERN,
1414
REMOVE_BOT_NAME_PATTERN,
15+
REMOVE_PLUGIN_IMPORT_NAME_PATTERN,
1516
REMOVE_PLUGIN_MODULE_NAME_PATTERN,
1617
REMOVE_PLUGIN_PROJECT_LINK_PATTERN,
1718
)
@@ -70,7 +71,10 @@ async def validate_author_info(issue: Issue, publish_type: PublishType) -> Remov
7071
case PublishType.PLUGIN | PublishType.ADAPTER:
7172
raw_data = extract_issue_info_from_issue(
7273
{
73-
"module_name": REMOVE_PLUGIN_MODULE_NAME_PATTERN,
74+
"module_name": [
75+
REMOVE_PLUGIN_MODULE_NAME_PATTERN,
76+
REMOVE_PLUGIN_IMPORT_NAME_PATTERN,
77+
],
7478
"project_link": REMOVE_PLUGIN_PROJECT_LINK_PATTERN,
7579
},
7680
body,

src/plugins/github/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,20 @@ def commit_message(prefix: str, message: str, issue_number: int):
2727

2828

2929
def extract_issue_info_from_issue(
30-
patterns: dict[str, Pattern[str]], body: str
30+
patterns: dict[str, Pattern[str] | list[Pattern[str]]], body: str
3131
) -> dict[str, str | None]:
3232
"""
3333
根据提供的正则表达式和议题内容来提取所需的信息
3434
"""
35-
matchers = {key: pattern.search(body) for key, pattern in patterns.items()}
35+
matchers = {}
36+
for key, pattern in patterns.items():
37+
if isinstance(pattern, list):
38+
matchers[key] = next(
39+
(p.search(body) for p in pattern if p.search(body)), None
40+
)
41+
else:
42+
matchers[key] = pattern.search(body)
43+
3644
# 如果未匹配到数据,则不添加进字典中
3745
# 这样可以让 Pydantic 在校验时报错 missing
3846
data = {key: match.group(1).strip() for key, match in matchers.items() if match}

tests/plugins/github/config/process/test_config_check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async def test_process_config_check(
134134
135135
nonebot-plugin-treehelp
136136
137-
### 插件 import 包名
137+
### 插件模块名
138138
139139
nonebot_plugin_treehelp
140140
@@ -223,7 +223,7 @@ async def test_process_config_check(
223223
224224
nonebot-plugin-treehelp
225225
226-
### 插件 import 包名
226+
### 插件模块名
227227
228228
nonebot_plugin_treehelp
229229

tests/plugins/github/config/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ def generate_issue_body(
33
project_link: str = "project_link",
44
config: str = "log_level=DEBUG",
55
):
6-
return f"""### PyPI 项目名\n\n{project_link}\n\n### 插件 import 包名\n\n{module_name}\n\n### 插件配置项\n\n```dotenv\n{config}\n```"""
6+
return f"""### PyPI 项目名\n\n{project_link}\n\n### 插件模块名\n\n{module_name}\n\n### 插件配置项\n\n```dotenv\n{config}\n```"""

tests/plugins/github/publish/process/test_publish_check_plugin.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async def test_plugin_process_publish_check(
134134
135135
project_link
136136
137-
### 插件 import 包名
137+
### 插件模块名
138138
139139
module_name
140140
@@ -163,7 +163,7 @@ async def test_plugin_process_publish_check(
163163
164164
project_link
165165
166-
### 插件 import 包名
166+
### 插件模块名
167167
168168
module_name
169169
@@ -400,7 +400,7 @@ async def test_plugin_process_publish_check_re_run(
400400
401401
project_link
402402
403-
### 插件 import 包名
403+
### 插件模块名
404404
405405
module_name
406406
@@ -429,7 +429,7 @@ async def test_plugin_process_publish_check_re_run(
429429
430430
project_link
431431
432-
### 插件 import 包名
432+
### 插件模块名
433433
434434
module_name
435435
@@ -650,7 +650,7 @@ async def test_plugin_process_publish_check_missing_metadata(
650650
651651
project_link
652652
653-
### 插件 import 包名
653+
### 插件模块名
654654
655655
module_name
656656
@@ -679,7 +679,7 @@ async def test_plugin_process_publish_check_missing_metadata(
679679
680680
project_link
681681
682-
### 插件 import 包名
682+
### 插件模块名
683683
684684
module_name
685685
@@ -861,7 +861,7 @@ async def test_skip_plugin_check(
861861
862862
project_link
863863
864-
### 插件 import 包名
864+
### 插件模块名
865865
866866
module_name
867867
@@ -900,7 +900,7 @@ async def test_skip_plugin_check(
900900
901901
project_link
902902
903-
### 插件 import 包名
903+
### 插件模块名
904904
905905
module_name
906906
@@ -938,7 +938,7 @@ async def test_skip_plugin_check(
938938
939939
project_link
940940
941-
### 插件 import 包名
941+
### 插件模块名
942942
943943
module_name
944944

tests/plugins/github/publish/utils/test_ensure_issue_plugin_test_button.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def test_ensure_issue_plugin_test_button(app: App, mocker: MockerFixture):
3333
3434
project_link
3535
36-
### 插件 import 包名
36+
### 插件模块名
3737
3838
module_name
3939
@@ -93,7 +93,7 @@ async def test_ensure_issue_plugin_test_button_checked(app: App, mocker: MockerF
9393
9494
project_link
9595
96-
### 插件 import 包名
96+
### 插件模块名
9797
9898
module_name
9999
@@ -182,7 +182,7 @@ async def test_ensure_issue_plugin_test_button_in_progress(
182182
183183
project_link
184184
185-
### 插件 import 包名
185+
### 插件模块名
186186
187187
module_name
188188

0 commit comments

Comments
 (0)