/**
 * Git Clone Utility
 *
 * Clones a git repository to a local path.
 * Used when registering projects to create the base clone
 * from which worktrees are later created.
 */

import { simpleGit } from 'simple-git';
import { createModuleLogger } from '../logger/index.js';

const log = createModuleLogger('git');

/**
 * Clone a git repository to a destination path.
 *
 * @param url - Remote repository URL
 * @param destPath - Local filesystem path for the clone
 */
export async function cloneProject(url: string, destPath: string): Promise<void> {
  const git = simpleGit();
  log.info({ url, destPath }, 'cloning project');
  await git.clone(url, destPath);
}
