From b5b15d1f768f6bf1116ea93a85e113acb500b09f Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 22 Jul 2026 08:43:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20check=5Fci=5Fstatus=E6=8C=89=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=97=B6=E9=97=B4=E5=8F=96=E6=9C=80=E6=96=B0status?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8Dauto-merge=E8=AF=AF=E7=AD=89pending?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check_ci_status.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/scripts/check_ci_status.py b/scripts/check_ci_status.py index 603071d50..96480f86a 100755 --- a/scripts/check_ci_status.py +++ b/scripts/check_ci_status.py @@ -31,20 +31,22 @@ def main(): print("pending") return - # API返回按时间倒序,第一个就是最新的 - for s in statuses: - if s.get("context") == target_context: - status = s.get("status", "pending") - # skipped 视为通过(条件跳过的任务不需要等) - if status == "skipped": - print("success") - else: - print(status) - return + # 筛选目标context,按时间倒序取最新的 + matching = [s for s in statuses if s.get("context") == target_context] + if not matching: + # 找不到说明CI还没开始写状态,返回pending继续等待 + print("pending") + return - # 找不到这个context说明CI还没开始写状态,返回pending继续等待 - # (如果workflow真的被跳过,它会有一条status为skipped的记录) - print("pending") + # Gitea statuses API按时间正序返回,必须取最新的一条 + latest = max(matching, key=lambda s: s.get("created_at", "")) + status = latest.get("status", "pending") + + # skipped 视为通过(条件跳过的任务不需要等) + if status == "skipped": + print("success") + else: + print(status) if __name__ == "__main__": -- 2.54.0