Files
backnotprop__plannotator/packages/server/vcs.ts
Michael Ramos 56df64c751 Add modern GitButler review support (#1067)
Adds current-architecture GitButler workspace, stack, and branch review support across Bun and Pi while preserving the existing Git, JJ, and P4 paths.

Co-authored-by: Dan Susman <56033661+dansusman@users.noreply.github.com>
2026-07-17 07:37:50 -07:00

87 lines
1.9 KiB
TypeScript

import {
type DiffType,
type GitDiffOptions,
type VcsProvider,
createGitButlerProvider,
createGitProvider,
createJjProvider,
createVcsApi,
resolveInitialDiffType,
} from "@plannotator/shared/vcs-core";
import {
detectP4Workspace,
getP4Context,
getP4FileContentsForDiff,
runP4Diff,
} from "./p4";
import { runtime as gitRuntime } from "./git";
import { runtime as gitButlerRuntime } from "./gitbutler";
import { runtime as jjRuntime } from "./jj";
const p4Provider: VcsProvider = {
id: "p4",
async detect(cwd?: string): Promise<boolean> {
return (await detectP4Workspace(cwd)) !== null;
},
ownsDiffType(diffType: string): boolean {
return diffType === "p4-default" || diffType.startsWith("p4-changelist:");
},
getContext: getP4Context,
runDiff(diffType: DiffType, _defaultBranch: string, cwd?: string, _options?: GitDiffOptions) {
return runP4Diff(diffType, cwd);
},
getFileContents(diffType, _defaultBranch, filePath, _oldPath?, cwd?) {
return getP4FileContentsForDiff(diffType, filePath, cwd);
},
};
const api = createVcsApi([
createJjProvider(jjRuntime),
createGitButlerProvider(gitButlerRuntime),
createGitProvider(gitRuntime),
p4Provider,
]);
export const {
detectVcs,
detectManagedVcs,
vcsOwnsDiffType,
getVcsContext,
detectRemoteDefaultCompareTarget,
prepareLocalReviewDiff,
runVcsDiff,
getVcsFileContentsForDiff,
getVcsDiffFingerprint,
canStageFiles,
stageFile,
unstageFile,
resolveVcsCwd,
} = api;
export { resolveInitialDiffType, gitRuntime };
export type {
DiffOption,
DiffType,
GitContext,
GitDiffOptions,
VcsProvider,
VcsSelection,
WorktreeInfo,
} from "@plannotator/shared/vcs-core";
export {
JJ_TRUNK_REVSET,
jjCompareTargetRevset,
jjLineBaseRevset,
parseCommitDiffType,
parseRemoteBookmark,
parseWorktreeDiffType,
validateFilePath,
} from "@plannotator/shared/vcs-core";