feat(FN-3217): honor resolved merge target across completion flows
- Add merge target branch resolver contract to core types and exports - Update task lifecycle completion path to resolve and propagate merge target branch - Use resolved merge target in merger execution instead of stale/default branch assumptions - Expand core and CLI tests for merge-target resolution behavior and add changeset for @runfusion/fusion Fusion-Task-Id: FN-3217
This commit is contained in:
@@ -1,5 +1,38 @@
|
||||
import type { Task, WorkflowStepResult } from "./types.js";
|
||||
|
||||
export interface MergeTargetResolution {
|
||||
branch: string;
|
||||
source: "task-base-branch" | "task-branch-context" | "project-default" | "legacy-main";
|
||||
}
|
||||
|
||||
export interface MergeTargetResolverOptions {
|
||||
projectDefaultBranch?: string;
|
||||
legacyFallbackBranch?: string;
|
||||
}
|
||||
|
||||
export function resolveTaskMergeTarget(
|
||||
task: Pick<Task, "baseBranch" | "branchContext">,
|
||||
options: MergeTargetResolverOptions = {},
|
||||
): MergeTargetResolution {
|
||||
const configuredBase = task.baseBranch?.trim();
|
||||
if (configuredBase) {
|
||||
return { branch: configuredBase, source: "task-base-branch" };
|
||||
}
|
||||
|
||||
const inheritedBase = task.branchContext?.inheritedBaseBranch?.trim();
|
||||
if (inheritedBase) {
|
||||
return { branch: inheritedBase, source: "task-branch-context" };
|
||||
}
|
||||
|
||||
const projectDefault = options.projectDefaultBranch?.trim();
|
||||
if (projectDefault) {
|
||||
return { branch: projectDefault, source: "project-default" };
|
||||
}
|
||||
|
||||
const legacyFallback = options.legacyFallbackBranch?.trim() || "main";
|
||||
return { branch: legacyFallback, source: "legacy-main" };
|
||||
}
|
||||
|
||||
const BLOCKING_TASK_STATUSES = new Set([
|
||||
"failed",
|
||||
// ── User-attention / awaiting-handoff states ─────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user