From 4b59a3d6297dcf80ec724df5022e0b7b29177e5e Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Fri, 21 Mar 2025 06:06:35 -0400 Subject: [PATCH] feat: compile regex pattern --- joint_teapot/app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/joint_teapot/app.py b/joint_teapot/app.py index 29227be..39e9a02 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -1002,6 +1002,11 @@ def joj3_check_env( items = group_config.split(",") comment = "" failed = False + pattern = re.compile( + r"joj3: update scoreboard for (?P.+?) " + r"by @(?P.+) in " + r"(?P.+)/(?P.+)@(?P.+)" + ) for item in items: name, values = item.split("=") max_count, time_period = map(int, values.split(":")) @@ -1013,12 +1018,7 @@ def joj3_check_env( commits = repo.iter_commits(paths=scoreboard_filename, since=since_git_format) for commit in commits: lines = commit.message.strip().splitlines() - pattern = ( - r"joj3: update scoreboard for (?P.+?) " - r"by @(?P.+) in " - r"(?P.+)/(?P.+)@(?P.+)" # 捕获 gitea_org_name, submitter_repo_name 和 commit_hash - ) - match = re.match(pattern, lines[0]) + match = pattern.match(lines[0]) if not match: continue d = match.groupdict()