fix: check_ci_status按时间取最新status,修复auto-merge一直等pending的bug #698
+15
-13
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user