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:
committed by
gsxdsm
parent
3d9260e0a8
commit
dacf45cba8
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user