@shutootaki/gwm
Version:
git worktree manager CLI
115 lines • 3.98 kB
TypeScript
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(): void;
/**
* worktreeを削除する
*/
export declare function removeWorktree(path: string, force?: boolean): 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): 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(): RemoteBranchInfo[];
/**
* メインワークツリーのパスを取得する
* 通常、最初のワークツリーがメインとなる
*/
export declare function getMainWorktreePath(): string | null;
/**
* gitignoreされたファイルのリストを取得
* @param workdir 検索対象のディレクトリ
* @param patterns 検索パターン(ワイルドカード対応)
* @param excludePatterns 除外パターン
*/
export declare function getIgnoredFiles(workdir: string, patterns: string[], excludePatterns?: string[]): string[];
/**
* ファイルを別のディレクトリにコピー
* @param sourceDir コピー元ディレクトリ
* @param targetDir コピー先ディレクトリ
* @param files コピーするファイルのリスト(相対パス)
* @returns コピーしたファイルのリスト
*/
export declare function copyFiles(sourceDir: string, targetDir: string, files: string[]): string[];
//# sourceMappingURL=git.d.ts.map