Skip to content

Commit 66ec403

Browse files
committed
🔧 Fix(Conflicts): Processed.
2 parents 9cac006 + 956cbd8 commit 66ec403

File tree

5 files changed

+68
-69
lines changed

5 files changed

+68
-69
lines changed

.github/workflows/pr-auto-rename.yml renamed to .github/workflows/pr-auto-format.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Check Pull Request Title
1+
name: Format Pull Request Title
22

33
on:
44
pull_request:
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
pull_request_number=${{ github.event.pull_request.number }}
3030
current_title="${{ github.event.pull_request.title }}"
31-
updated_title=$(python3 "./ToolKits/Actions/pr_auto_rename.py" "$current_title")
31+
updated_title=$(python3 "./ToolKits/Actions/pr_format.py" "$current_title")
3232
3333
curl -X PATCH \
3434
-H "Authorization: Bearer ${{ secrets.GITHUBTOKEN }}" \

KitX SDK

Submodule KitX SDK updated 1 file

ToolKits/Actions/pr_auto_rename.py

-63
This file was deleted.

ToolKits/Actions/pr_format.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""
2+
Format the pull request title to the standard format.
3+
"""
4+
5+
import sys
6+
import re
7+
8+
# Chinese replacement.
9+
replacemap = {
10+
# Brackets.
11+
"(": "(",
12+
")": ")",
13+
"『": "[",
14+
"』": "]",
15+
"「": "[",
16+
"」": "]",
17+
"【": "[",
18+
"】": "]",
19+
"〔": "{",
20+
"〕": "}",
21+
# Quotation marks.
22+
"‘": "'",
23+
"’": "'",
24+
"“": '"',
25+
"”": '"',
26+
",": ", ",
27+
"。": ". ",
28+
";": "; ",
29+
":": ": ",
30+
"?": "? ",
31+
"!": "! ",
32+
"、": ", ",
33+
"…": "...",
34+
"—": "-",
35+
"·": ".",
36+
"~": "~",
37+
}
38+
39+
40+
HEAD = "[Pull Request]"
41+
FORMAT_REGEX = r"^(\[?[pP][rR]\]?|\[?[pP][uU][lL][lL][- _]?[rR][eE][qQ][uU][eE][sS][tT]\]?|\[?[pP][uU][lL][lL]\]?)([^\n]*)$" # pylint: disable=line-too-long
42+
43+
if __name__ == "__main__":
44+
if len(sys.argv) < 2:
45+
print(f"Usage: python {sys.argv[0]} <title>")
46+
sys.exit(1)
47+
title = sys.argv[1]
48+
49+
# Step 1: Convert Chinese to English.
50+
for key, value in replacemap.items():
51+
title = title.replace(key, value)
52+
53+
# Step 2: Check and update the name of PR.
54+
if not title.startswith(HEAD):
55+
result = re.match(FORMAT_REGEX, title, re.M | re.I)
56+
if result:
57+
title = f"{HEAD} {result.group(2).strip()}"
58+
else:
59+
title = f"{HEAD} {title.strip()}"
60+
61+
print(title)
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
1+

22

33
# <emoji> <types>(<scope>): <subject>
44
# <emoji>: 💾/🔧/📄/🎇/🧩/✅/❌/📝/📦/🐛
55
# <types>: Feat/Fix/Docs/Style/Refactor/Test/Test/Chore/Struct/Bug
66
# demo: 💾 📝 📦 Feat, Chore, Struct(Scope): issue or changelog
7+
# docs: https://docs.catrol.cn/rules/team/git/#%25E6%258F%2590%25E4%25BA%25A4%25E6%25B6%2588%25E6%2581%25AF%25E8%25A7%2584%25E8%258C%2583
78

89
# <body>
910

1011
# <footer> (Breaking Changes)
1112

12-
# Date:
13-
# Author:
13+
# Date:
14+
# Author:

0 commit comments

Comments
 (0)