mirror of
https://github.com/makecindy/cindy.git
synced 2026-12-02 09:20:13 +08:00
fix(cindy-make): Sync 读基线前校验其为个人 tip 的祖先
thread 4163517139:sourceRevisions 与 upstreamMergeRuntime 的读取都已加 「记录基线必须是个人 tip 的祖先」的 clamp,但 Sync 自己的基线读取器 (`personalSyncRuntime.base`)仍原样返回记录值。中断移动留下的「旧 tip + 新基线」会让 Sync 看到 `base === target.commit`、跳过必需的官方更新,反复 报完成而源码仍停在旧版。同口径补上:错配时按两者共同历史推算的基线回落, 推算不出再走原有的 derived 回退。 验证:desktop typecheck 通过;src/main/cindy-make 单测 1148 通过; cindy-make git-integration 90 通过。 Signed-off-by: MagicLizi <jiali@magiclizi.com>
This commit is contained in:
@@ -100,12 +100,22 @@ export function configurePersonalSync(): void {
|
||||
target: resolveSyncTarget,
|
||||
base: async () => {
|
||||
const recorded = await readCommit(PERSONAL_UPSTREAM_REF);
|
||||
if (recorded) return recorded;
|
||||
const personal = await readCommit(`refs/heads/${CINDY_PERSONAL_BRANCH}`);
|
||||
// The recorded base is trusted only as the personal tip's ancestor — the
|
||||
// same clamp as the source-status and merge-runtime reads: an interrupted
|
||||
// move leaves "old tip + new base", and Sync seeing that base would skip
|
||||
// the update it needs while the source stays old. The shared history of
|
||||
// the two recovers the base the tip really sits on.
|
||||
if (recorded && (!personal || (await isAncestor(recorded, personal)))) return recorded;
|
||||
const clamped =
|
||||
recorded && personal
|
||||
? (await git(['merge-base', personal, recorded]).catch(() => '')).trim()
|
||||
: '';
|
||||
if (COMMIT.test(clamped)) return clamped;
|
||||
// Sources prepared before the base was recorded: the official commit they were made
|
||||
// from (the same fallback the status uses). Recorded once so the combine reads it too.
|
||||
const tools = await createMakeToolchainEnvironment(userData);
|
||||
const derived = (await readCurrentCindySourceStatus(root, tools)).baseCommit;
|
||||
const personal = await readCommit(`refs/heads/${CINDY_PERSONAL_BRANCH}`);
|
||||
if (!derived || !COMMIT.test(derived) || !personal || !(await isAncestor(derived, personal)))
|
||||
return undefined;
|
||||
// Create-only: never overwrites a base recorded meanwhile.
|
||||
|
||||
Reference in New Issue
Block a user