11import { pathToFileURL } from "node:url" ;
22import type * as github from "@actions/github" ;
33import { getReleasePlan } from "@changesets/get-release-plan" ;
4- import { createFixture } from "fs-fixture" ;
54import { exec } from "tinyexec" ;
65import { describe , expect , it } from "vitest" ;
6+ import { gitdir , shallowClone , testdir } from "../test-utils/index.ts" ;
77import { getPullRequestWorktree } from "./worktree.ts" ;
88
99type PullRequestContext = NonNullable <
@@ -21,7 +21,7 @@ async function git(cwd: string, args: string[]) {
2121describe ( "getPullRequestWorktree" , ( ) => {
2222 it ( "fetches a PR branch into a detached worktree and keeps the main checkout untouched" , async ( ) => {
2323 // Local source repo
24- await using sourceRepoFixture = await createFixture ( {
24+ await using sourceRepoFixture = await gitdir ( {
2525 ".changeset/config.json" : JSON . stringify ( { } ) ,
2626 "package.json" : JSON . stringify ( {
2727 name : "repo" ,
@@ -35,46 +35,33 @@ describe("getPullRequestWorktree", () => {
3535 } ) ,
3636 } ) ;
3737 const sourceRepo = sourceRepoFixture . path ;
38- await git ( sourceRepo , [ "init" , "-b" , "main" ] ) ;
39- await git ( sourceRepo , [ "config" , "user.name" , "Test User" ] ) ;
40- await git ( sourceRepo , [ "config" , "user.email" , "test@example.com" ] ) ;
41- await git ( sourceRepo , [ "add" , "." ] ) ;
42- await git ( sourceRepo , [ "commit" , "-m" , "base" ] ) ;
4338
4439 // Simulate remote bare git server
45- await using originBareFixture = await createFixture ( ) ;
40+ await using originBareFixture = await testdir ( ) ;
4641 const originBare = originBareFixture . path ;
47- await git ( originBare , [ "clone" , "--bare" , sourceRepo , originBare ] ) ;
42+ await git ( originBare , [
43+ "clone" ,
44+ "--bare" ,
45+ pathToFileURL ( sourceRepo ) . toString ( ) ,
46+ "." ,
47+ ] ) ;
4848
4949 // Simulate checkout PR in github action
50- await using checkoutRepoFixture = await createFixture ( ) ;
50+ await using checkoutRepoFixture = await shallowClone ( originBare ) ;
5151 const checkoutRepo = checkoutRepoFixture . path ;
52- await git ( checkoutRepo , [
53- "clone" ,
54- "--depth" ,
55- "1" ,
56- "--branch" ,
57- "main" ,
58- pathToFileURL ( originBare ) . toString ( ) ,
59- checkoutRepo ,
60- ] ) ;
6152
6253 // Simulate remote fork bare git server
63- await using forkBareFixture = await createFixture ( ) ;
54+ await using forkBareFixture = await testdir ( ) ;
6455 const forkBare = forkBareFixture . path ;
65- await git ( forkBare , [ "clone" , "--bare" , originBare , forkBare ] ) ;
66-
67- await using forkRepoFixture = await createFixture ( ) ;
68- const forkRepo = forkRepoFixture . path ;
69- await git ( forkRepo , [
56+ await git ( forkBare , [
7057 "clone" ,
71- "--depth" ,
72- "1" ,
73- "--branch" ,
74- "main" ,
75- pathToFileURL ( forkBare ) . toString ( ) ,
76- forkRepo ,
58+ "--bare" ,
59+ pathToFileURL ( originBare ) . toString ( ) ,
60+ "." ,
7761 ] ) ;
62+
63+ await using forkRepoFixture = await shallowClone ( forkBare ) ;
64+ const forkRepo = forkRepoFixture . path ;
7865 await git ( forkRepo , [ "config" , "user.name" , "Test User" ] ) ;
7966 await git ( forkRepo , [ "config" , "user.email" , "test@example.com" ] ) ;
8067 await git ( forkRepo , [ "checkout" , "-b" , "feature" ] ) ;
0 commit comments