fix(ci-status): get_ci_status 结论区分三态——pending 不再误输出 ❌
add has_failure flag,使结论由两态(pass/fail)扩展为三态: ✅ 全部通过 / ⏳ 检查进行中 / ❌ 存在失败检查。 修复前 pending 和 failure 均输出 ❌,/ship 轮询无法区分排队与真实失败。 Feature-Confirmed: true
This commit is contained in:
parent
c12e8df0ae
commit
ca67e188c0
@ -781,6 +781,7 @@ pub fn gitea_api_get_ci_status(project_id: &str, commit_sha: &str) -> Result<Str
|
||||
|
||||
let mut lines = vec![format!("## CI 状态:commit `{}`\n", short_sha)];
|
||||
let mut all_pass = true;
|
||||
let mut has_failure = false;
|
||||
for (ctx, s) in &latest {
|
||||
// Gitea 1.22 Actions 使用 "status" 字段;传统 commit status API 用 "state"
|
||||
let state = s["status"].as_str()
|
||||
@ -789,15 +790,17 @@ pub fn gitea_api_get_ci_status(project_id: &str, commit_sha: &str) -> Result<Str
|
||||
let desc = s["description"].as_str().unwrap_or("");
|
||||
let icon = match state {
|
||||
"success" => "✅",
|
||||
"failure" | "error" => { all_pass = false; "❌" },
|
||||
"failure" | "error" => { all_pass = false; has_failure = true; "❌" },
|
||||
_ => { all_pass = false; "⏳" },
|
||||
};
|
||||
lines.push(format!("- {} `{}` — {} {}", icon, ctx, state, desc));
|
||||
}
|
||||
let conclusion = if all_pass {
|
||||
"✅ 全部通过,可以合并"
|
||||
} else if has_failure {
|
||||
"❌ 存在失败检查,暂不建议合并"
|
||||
} else {
|
||||
"❌ 存在失败或等待中的检查,暂不建议合并"
|
||||
"⏳ 检查进行中,请稍后再查"
|
||||
};
|
||||
lines.push(format!("\n**结论:{}**", conclusion));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user