MCPcopy
hub / github.com/coder/mux / createWorktreeManagerFixture

Function createWorktreeManagerFixture

src/node/worktree/WorktreeManager.test.ts:31–63  ·  view source on GitHub ↗
(options?: {
  existingBranchName?: string;
  currentBranchName?: string;
  tempDirPrefix?: string;
})

Source from the content-addressed store, hash-verified

29}
30
31async function createWorktreeManagerFixture(options?: {
32 existingBranchName?: string;
33 currentBranchName?: string;
34 tempDirPrefix?: string;
35}) {
36 const rootDir = await fsPromises.realpath(
37 await fsPromises.mkdtemp(
38 path.join(os.tmpdir(), options?.tempDirPrefix ?? "worktree-manager-create-")
39 )
40 );
41 const projectPath = path.join(rootDir, "repo");
42 await fsPromises.mkdir(projectPath, { recursive: true });
43 initGitRepo(projectPath);
44
45 if (options?.currentBranchName) {
46 execSync(`git checkout -b ${options.currentBranchName}`, { cwd: projectPath, stdio: "ignore" });
47 }
48
49 if (options?.existingBranchName) {
50 execSync(`git branch ${options.existingBranchName}`, { cwd: projectPath, stdio: "ignore" });
51 }
52
53 const srcBaseDir = path.join(rootDir, "src");
54 await fsPromises.mkdir(srcBaseDir, { recursive: true });
55
56 return {
57 rootDir,
58 projectPath,
59 manager: new WorktreeManager(srcBaseDir),
60 initLogger: createNullInitLogger(),
61 cleanup: () => fsPromises.rm(rootDir, { recursive: true, force: true }),
62 };
63}
64
65describe("WorktreeManager constructor", () => {
66 it("should expand tilde in srcBaseDir", () => {

Callers 1

Calls 2

initGitRepoFunction · 0.70
createNullInitLoggerFunction · 0.70

Tested by

no test coverage detected