TypeScript
fix(server): end clone options before the repository URL (#14781)
Alex Southwelle65063ccf6ce
diff --git a/apps/server/src/sourceControl/SourceControlRepositoryService.test.ts b/apps/server/src/sourceControl/SourceControlRepositoryService.test.tsindex fa9a4b885e1..8ee62bbaffe 100644--- a/apps/server/src/sourceControl/SourceControlRepositoryService.test.ts+++ b/apps/server/src/sourceControl/SourceControlRepositoryService.test.ts@@ -179,7 +179,7 @@ it.effect("clones a looked-up repository into the requested destination", () =>assert.deepStrictEqual(cloneCalls, [{cwd: parent,- args: ["clone", "--progress", CLONE_URLS.url, "t3code"],+ args: ["clone", "--progress", "--", CLONE_URLS.url, "t3code"],},]);}).pipe(@@ -198,6 +198,43 @@ it.effect("clones a looked-up repository into the requested destination", () =>}).pipe(Effect.provide(NodeServices.layer)),);+it.effect.each(["--bare", "source.git"])(+ "clones a local repository named %s as a working tree",+ (repositoryName) =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const git = yield* GitVcsDriver.GitVcsDriver;+ const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-clone-options-" });+ yield* git.execute({+ operation: "test.init",+ cwd: parent,+ args: ["init", "--bare", path.join(parent, repositoryName)],+ });+ const destinationPath = path.join(parent, "checkout");+ yield* Effect.gen(function* () {+ const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;+ const result = yield* service.cloneRepository({+ remoteUrl: repositoryName,+ destinationPath,+ });+ assert.strictEqual(result.cwd, destinationPath);+ assert.isTrue(yield* fs.exists(path.join(destinationPath, ".git")));+ }).pipe(Effect.provide(makeLayer({ git: { execute: git.execute } })));+ }).pipe(+ Effect.provide(+ GitVcsDriver.layer.pipe(+ Layer.provide(+ ServerConfig.layerTest(process.cwd(), {+ prefix: "t3-clone-options-config-",+ }),+ ),+ Layer.provideMerge(NodeServices.layer),+ ),+ ),+ ),+);+it.effect("reports clone progress from git's stderr and keeps its error text on failure", () =>Effect.gen(function* () {const fs = yield* FileSystem.FileSystem;diff --git a/apps/server/src/sourceControl/SourceControlRepositoryService.ts b/apps/server/src/sourceControl/SourceControlRepositoryService.tsindex eaf65b5cd66..ebab84b53a2 100644--- a/apps/server/src/sourceControl/SourceControlRepositoryService.ts+++ b/apps/server/src/sourceControl/SourceControlRepositoryService.ts@@ -303,7 +303,13 @@ export const make = Effect.gen(function* () {.execute({operation: "SourceControlRepositoryService.cloneRepository",cwd: path.dirname(prepared.destinationPath),- args: ["clone", "--progress", prepared.cloneUrl, path.basename(prepared.destinationPath)],+ args: [+ "clone",+ "--progress",+ "--",+ prepared.cloneUrl,+ path.basename(prepared.destinationPath),+ ],timeoutMs: options?.timeoutMs === undefined ? CLONE_TIMEOUT_MS : options.timeoutMs,// Progress redraws add up on a slow multi-GB clone. The buffered copy// is never read (the tail is kept by hand above), so keep it small