import { execute as executeSquash } from '../squash/execute.js';
import type { RebaseSnapshotSpec, RebaseSnapshotResult } from './types.js';

/**
 * rebase-snapshot re-uses the squash implementation. The difference is
 * intent: squash is called before merging a feature branch, rebase-snapshot
 * is called after a rebase that left ModelSnapshot.cs in a conflicted
 * state. Both end up in the same place: one consolidated migration on top
 * of the base branch's snapshot.
 */
export async function execute(spec: RebaseSnapshotSpec): Promise<RebaseSnapshotResult> {
  return executeSquash({
    cwd: spec.cwd,
    contextName: spec.contextName,
    description: spec.description,
    assembly: spec.assembly,
    baseBranch: spec.baseBranch,
    dryRun: spec.dryRun ?? false,
    aggressive: false,
  });
}
