UNPKG

@shutootaki/gwm

Version:
127 lines 4.58 kB
export interface Worktree { path: string; branch: string; head: string; status: string; isActive: boolean; isMain: boolean; } /** * git worktree list --porcelain の出力をパースする */ export declare function parseWorktrees(output: string): Worktree[]; /** * worktreeのリストを取得し、PRUNABLE状態を判定する */ export declare function getWorktreesWithStatus(): Promise<Worktree[]>; /** * git fetch --prune origin を実行(非同期版) */ export declare function fetchAndPrune(): Promise<void>; /** * worktreeを削除する(非同期版) */ export declare function removeWorktree(path: string, force?: boolean): Promise<void>; /** * Gitリポジトリ名を取得する * リモートのorigin URLからリポジトリ名を抽出する * フォールバックとして現在のディレクトリ名を使用する */ export declare function getRepositoryName(): string; export interface PullResult { branch: string; path: string; success: boolean; message: string; } /** * メインブランチ(複数可)のworktreeでgit pullを実行する */ export declare function pullMainBranch(): Promise<PullResult[]>; /** * ローカルブランチが存在するか確認 */ export declare function localBranchExists(branch: string): boolean; /** * ブランチに未マージコミットがあるかを簡易判定 * origin/<branch> が存在する場合に限り git cherry で差分を確認。 * 取得に失敗した場合は true を返し、安全側で未マージとみなす。 */ export declare function hasUnmergedCommits(branch: string): boolean; /** * ローカルブランチを削除する (未マージコミットがある場合は -D を要求)(非同期版) */ export declare function deleteLocalBranch(branch: string, force?: boolean): Promise<void>; export interface CleanableWorktree { worktree: Worktree; reason: 'remote_deleted' | 'merged'; mergedIntoBranch?: string; } /** * リモートブランチの状態を確認 * - isDeleted: origin/<branch> が存在しない * - isMerged : ブランチがいずれかの mainBranch にマージ済み */ export declare function checkRemoteBranchStatus(branch: string, mainBranches: string[]): { isDeleted: boolean; isMerged: boolean; mergedIntoBranch?: string; }; /** * ワークツリーパスでローカル変更を確認 */ export declare function checkLocalChanges(worktreePath: string): { hasUnstagedChanges: boolean; hasUntrackedFiles: boolean; hasStagedChanges: boolean; hasLocalCommits: boolean; }; /** * 削除可能なワークツリーを取得 */ export declare function getCleanableWorktrees(): Promise<CleanableWorktree[]>; export declare function getRepoRoot(): string; export interface RemoteBranchInfo { name: string; fullName: string; lastCommitDate: string; lastCommitterName: string; lastCommitMessage: string; } /** * リモートブランチの詳細情報を取得する(非同期版) */ export declare function getRemoteBranchesWithInfo(): Promise<RemoteBranchInfo[]>; /** * メインワークツリーのパスを取得する * 通常、最初のワークツリーがメインとなる */ export declare function getMainWorktreePath(): string | null; /** * gitignoreされたファイルのリストを取得 * @param workdir 検索対象のディレクトリ * @param patterns 検索パターン(ワイルドカード対応) * @param excludePatterns 除外パターン */ export declare function getIgnoredFiles(workdir: string, patterns: string[], excludePatterns?: string[], /** * 仮想環境ディレクトリをスキップするかどうか。 * true : isVirtualEnv() に一致したディレクトリを走査対象から除外 (既定) * false : 仮想環境も通常ディレクトリとして扱う */ skipVirtualEnvs?: boolean): string[]; export interface CopyFilesResult { copied: string[]; skippedVirtualEnvs: string[]; skippedOversize: string[]; } /** * ファイルを別のディレクトリにコピー * シンボリックリンクを適切に処理し、仮想環境は除外 * @param sourceDir コピー元ディレクトリ * @param targetDir コピー先ディレクトリ * @param files コピーするファイルのリスト(相対パス) * @returns コピーしたファイルのリスト */ export declare function copyFiles(sourceDir: string, targetDir: string, files: string[]): Promise<CopyFilesResult>; //# sourceMappingURL=git.d.ts.map