feat(FN-4700): complete Step 2 — add no-changes-finalized classifier

Fusion-Task-Id: FN-4700
Fusion-Task-Lineage: 87097576-c2be-4be4-8e10-9af85831fe5d
This commit is contained in:
Fusion (runfusion.ai)
2026-05-15 20:04:39 -07:00
committed by gsxdsm
parent 3d9260e0a8
commit dacf45cba8
2 changed files with 155 additions and 0 deletions

View File

@@ -406,6 +406,15 @@ interface OwnedLandedCommit {
export type OwnedLandedClassification =
| { kind: "owned-commit"; commit: OwnedLandedCommit }
| { kind: "proven-no-op"; baseRef: string; ownDiffEmpty: true }
| {
kind: "no-changes-finalized";
baseRef: string;
details: {
branchExists: boolean;
aheadCount: number | null;
baseReachableFromTarget: boolean;
};
}
| {
kind: "unproven";
reason: "foreign-start-point" | "no-owned-commit-foreign-deltas" | "missing-evidence";
@@ -518,6 +527,26 @@ export async function classifyOwnedLandedEvidence(
return { kind: "proven-no-op", baseRef: mergeTargetBranch, ownDiffEmpty: true };
}
let branchExists = false;
try {
await execFileAsync("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], { cwd: rootDir });
branchExists = true;
} catch {
branchExists = false;
}
if (!ownedCommit && !branchExists && aheadCount === null && (baseReachableFromTarget || !task.baseCommitSha)) {
return {
kind: "no-changes-finalized",
baseRef: mergeTargetBranch,
details: {
branchExists,
aheadCount,
baseReachableFromTarget,
},
};
}
if (task.baseCommitSha && !baseReachableFromTarget) {
try {
const { stdout } = await execFileAsync("git", ["for-each-ref", "--format=%(refname:short)", "refs/heads/fusion"], {
@@ -581,6 +610,7 @@ export async function classifyOwnedLandedEvidence(
branch,
mergeTargetBranch,
aheadCount,
branchExists,
baseCommitShaPresent: Boolean(task.baseCommitSha),
baseReachableFromTarget,
hasOwnedCommit: Boolean(ownedCommit),