/** * BranchManager Port Interface * * Manages branch-level git operations (create, merge, diff, delete) * across project clones. Works directly on branches without requiring * a worktree to be checked out. */ import type { MergeResult, BranchCommit } from './types.js'; export interface BranchManager { /** * Ensure a branch exists. Creates it from baseBranch if it doesn't. * Idempotent — no-op if the branch already exists. */ ensureBranch(repoPath: string, branch: string, baseBranch: string): Promise; /** * Merge sourceBranch into targetBranch. * Uses an ephemeral worktree for merge safety. * Returns conflict info if merge fails. */ mergeBranch(repoPath: string, sourceBranch: string, targetBranch: string): Promise; /** * Get the raw unified diff between two branches. * Uses three-dot diff (baseBranch...headBranch) to show changes * introduced by headBranch since it diverged from baseBranch. */ diffBranches(repoPath: string, baseBranch: string, headBranch: string): Promise; /** * Delete a branch. No-op if the branch doesn't exist. */ deleteBranch(repoPath: string, branch: string): Promise; /** * Check if a branch exists in the repository. */ branchExists(repoPath: string, branch: string): Promise; /** * Check if a branch exists as a remote tracking branch (origin/). * Useful for validating branch names against what the remote has, * since local branches may not include all remote branches. */ remoteBranchExists(repoPath: string, branch: string): Promise; /** * List commits that headBranch has but baseBranch doesn't. * Used for commit-level navigation in code review. */ listCommits(repoPath: string, baseBranch: string, headBranch: string): Promise; /** * Get the raw unified diff for a single commit. */ diffCommit(repoPath: string, commitHash: string): Promise; }