Close trial task cards and keep long histories visible

Why: pipefail treated a recent merged-card match as a failed git log after grep exited early, hiding completed cards from precheck and task-close.

Evidence: A disposable long-history regression failed before the fix and passed after it; make test-governance passed 341 cases. Git history confirms PR #489/#488/#486 merge SHAs.

Impact: Detect merged cards reliably and archive only the three authorized trial cards; four unrelated eligible cards remain untouched.

Refs: Dev merge queue #518; Dev #489, #488, #486
This commit is contained in:
2026-10-14 04:50:06 +00:00
parent 05b997b84d
commit deff43ae59
5 changed files with 33 additions and 2 deletions
+4 -2
View File
@@ -57,7 +57,9 @@ cmd_precheck() {
pb=$(card_of_branch "$pc"); [ -n "$pb" ] || continue
pst=$(card_status "$pc"); case "$pst" in 已完成*) continue ;; esac
card_pending "${pc##*/}" && continue
if git log --merges --format='%s' "origin/${TARGET_BRANCH}" 2>/dev/null | grep -qF " from $pb into ${TARGET_BRANCH}"; then
# Consume the complete producer output: grep -q exits on the first match,
# making git log die with SIGPIPE (141 under pipefail) on long histories.
if git log --merges --format='%s' "origin/${TARGET_BRANCH}" 2>/dev/null | grep -F " from $pb into ${TARGET_BRANCH}" >/dev/null; then
open_cards="${open_cards} ${pc##*/}"
fi
done
@@ -379,7 +381,7 @@ card_of_branch() { sed -n 's/^- 工作区:.*分支:\([A-Za-z0-9._/-]\+\).*/\
card_status() { sed -n 's/^.*;状态:\([^;]*\).*/\1/p' "$1" | head -1; }
card_merge() { # $1=branch → "sha|subject"(该分支合入 origin/<target> 的合并提交)
git log --merges --format='%H|%s' "origin/${TARGET_BRANCH}" 2>/dev/null \
| grep -F " from $1 into ${TARGET_BRANCH}" | head -1
| grep -F " from $1 into ${TARGET_BRANCH}" | sed -n '1p'
}
card_pending() { # $1=卡片文件名——闭合是否已在某 origin/feature/card-close-* 分支待合入
local cb