Avoid new commits when the task already contains the integration baseline

Why: repeated task-sync calls changed HEAD and invalidated CI even when main had not advanced.

Evidence: SELF red-green regression and 58 task lifecycle tests recorded through make evidence in the task card.

Impact: sync still fetches and validates components, creates records only for an actual merge, and reports the complete final source SHA.

Refs: U1; policy/merge-queue.md; .task/feature-merge-queue-policy-draft.md
This commit is contained in:
2026-10-13 07:05:06 +00:00
parent af223189f3
commit 03cbeac8e6
2 changed files with 112 additions and 16 deletions
+27 -16
View File
@@ -278,18 +278,26 @@ cmd_sync() {
need_repo
fetch_target
check_worktree before-sync
git merge --no-edit "origin/${TARGET_BRANCH}" \
-m "Merge authoritative ${TARGET_BRANCH} into the task branch" \
-m "Why: include the current integration baseline before verification." \
-m "Evidence: fetched origin/${TARGET_BRANCH}=$(git rev-parse "origin/${TARGET_BRANCH}")." \
-m "Impact: integrate upstream changes without rewriting task history." \
-m "Refs: task-sync"
git merge-base --is-ancestor "origin/${TARGET_BRANCH}" HEAD || die "sync incomplete"
local base head card branch slug pc changed=0 ancestry_status
base=$(git rev-parse "origin/${TARGET_BRANCH}")
if git merge-base --is-ancestor "$base" HEAD; then
:
else
ancestry_status=$?
[ "$ancestry_status" -eq 1 ] || die "cannot verify target ancestry"
git merge --no-edit "$base" \
-m "Merge authoritative ${TARGET_BRANCH} into the task branch" \
-m "Why: include the current integration baseline before verification." \
-m "Evidence: fetched origin/${TARGET_BRANCH}=${base}." \
-m "Impact: integrate upstream changes without rewriting task history." \
-m "Refs: task-sync"
changed=1
fi
git merge-base --is-ancestor "$base" HEAD || die "sync incomplete"
check_worktree before-update
check_worktree materialize
check_worktree after-sync
local base head card branch slug pc
base=$(git rev-parse "origin/${TARGET_BRANCH}"); head=$(git rev-parse HEAD)
head=$(git rev-parse HEAD)
branch=$(git rev-parse --abbrev-ref HEAD)
slug=$(echo "$branch" | tr '/' '-')
card=".task/${slug}.md"
@@ -304,18 +312,21 @@ cmd_sync() {
done
fi
if [ -n "$card" ] && [ -f "$card" ]; then
printf '| 同步前验收 | %s | %s | %s |\n' "$base" "$head" "$(date -u +%FT%TZ)" >> "$card"
git add "$card"
git commit -q -m "Record the sync checkpoint" \
-m "Why: bind the task validation checkpoint to the latest integration baseline." \
-m "Evidence: SELF recursive component checks; sync_base=${base}; candidate=${head}." \
-m "Impact: task metadata only." -m "Refs: ${card}"
if [ "$changed" -eq 1 ]; then
printf '| 同步(记录前对象) | %s | %s | %s |\n' "$base" "$head" "$(date -u +%FT%TZ)" >> "$card"
git add "$card"
git commit -q -m "Record the sync checkpoint" \
-m "Why: bind the task validation checkpoint to the integration baseline." \
-m "Evidence: SELF recursive component checks; sync_base=${base}; before_record=${head}." \
-m "Impact: task metadata only." -m "Refs: ${card}" -- "$card"
fi
# JSON receipts carry before/after state; older table rows remain readable.
python3 "${SCRIPT_DIR}/check-evidence.py" "$card"
else
echo "[warn] 找不到分支 ${branch} 的任务卡,同步记录未写入" >&2
fi
echo "[synced] sync_base=$(echo "$base" | cut -c1-10) tested_head=$(echo "$head" | cut -c1-10) checked_at=$(date -u +%FT%TZ)"
head=$(git rev-parse HEAD)
echo "[synced] sync_base=${base} tested_head=${head} checked_at=$(date -u +%FT%TZ) changed=${changed}"
echo "[next] 跑正式验收(make test 等),证据写入任务卡"
}