| ... | ... | @@ -35,6 +35,7 @@ import { |
| 35 | 35 | makeGitVcsDriverCore, |
| 36 | 36 | parseGitCheckoutProgressLine, |
| 37 | 37 | splitNullSeparatedGitStdoutPaths, |
| 38 | windowsLongPathConfigEnv, |
| 38 | 39 | } from "./GitVcsDriverCore.ts"; |
| 39 | 40 | import * as GitVcsDriver from "./GitVcsDriver.ts"; |
| 40 | 41 | |
| ... | ... | @@ -3955,3 +3956,94 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => { |
| 3955 | 3956 | ); |
| 3956 | 3957 | }); |
| 3957 | 3958 | }); |
| 3959 | |
| 3960 | describe("Windows long path configuration", () => { |
| 3961 | const readGitConfig = Effect.fn("readGitConfig")(function* ( |
| 3962 | platform: NodeJS.Platform, |
| 3963 | key: string, |
| 3964 | ) { |
| 3965 | const layer = GitVcsDriver.layer.pipe( |
| 3966 | Layer.provide(layerServerConfig), |
| 3967 | Layer.provideMerge(NodeServices.layer), |
| 3968 | Layer.provide(Layer.succeed(HostProcessPlatform, platform)), |
| 3969 | ); |
| 3970 | return yield* Effect.gen(function* () { |
| 3971 | const driver = yield* GitVcsDriver.GitVcsDriver; |
| 3972 | const cwd = yield* makeTmpDir("git-longpath-test-"); |
| 3973 | const result = yield* driver.execute({ |
| 3974 | operation: "GitVcsDriverTest.readGitConfig", |
| 3975 | cwd, |
| 3976 | args: ["config", "--get", key], |
| 3977 | // Replaces the suite's own core.longpaths=true so it cannot mask a |
| 3978 | // missing injection. Entry 2 sits past the count and must stay unread. |
| 3979 | env: { |
| 3980 | GIT_CONFIG_COUNT: "2", |
| 3981 | GIT_CONFIG_KEY_0: "user.name", |
| 3982 | GIT_CONFIG_VALUE_0: "inherited-name", |
| 3983 | GIT_CONFIG_KEY_1: "core.longpaths", |
| 3984 | GIT_CONFIG_VALUE_1: "false", |
| 3985 | GIT_CONFIG_KEY_2: "user.name", |
| 3986 | GIT_CONFIG_VALUE_2: "outside-count", |
| 3987 | }, |
| 3988 | }); |
| 3989 | return result.stdout.trim(); |
| 3990 | }).pipe(Effect.provide(layer), Effect.scoped); |
| 3991 | }); |
| 3992 | |
| 3993 | it.effect("enables long paths for every Git command on Windows", () => |
| 3994 | Effect.gen(function* () { |
| 3995 | assert.equal(yield* readGitConfig("win32", "core.longpaths"), "true"); |
| 3996 | assert.equal(yield* readGitConfig("win32", "user.name"), "inherited-name"); |
| 3997 | }), |
| 3998 | ); |
| 3999 | |
| 4000 | it.effect("leaves Git config untouched on other platforms", () => |
| 4001 | Effect.gen(function* () { |
| 4002 | assert.equal(yield* readGitConfig("linux", "core.longpaths"), "false"); |
| 4003 | assert.equal(yield* readGitConfig("linux", "user.name"), "inherited-name"); |
| 4004 | }), |
| 4005 | ); |
| 4006 | |
| 4007 | it("extends an inherited count spelled in a different case", () => { |
| 4008 | // Two spellings collapse to one on spawn (the uppercase one wins), so the |
| 4009 | // count must be bumped under the spelling that is already there. |
| 4010 | assert.deepStrictEqual(windowsLongPathConfigEnv("win32", { git_config_count: "2" }), { |
| 4011 | git_config_count: "3", |
| 4012 | GIT_CONFIG_KEY_2: "core.longpaths", |
| 4013 | GIT_CONFIG_VALUE_2: "true", |
| 4014 | }); |
| 4015 | }); |
| 4016 | |
| 4017 | it("appends after inherited entries, parsing the count as Git does", () => { |
| 4018 | for (const [count, next] of [ |
| 4019 | [undefined, 0], |
| 4020 | ["", 0], |
| 4021 | ["0", 0], |
| 4022 | ["-0", 0], |
| 4023 | ["2", 2], |
| 4024 | [" 2", 2], |
| 4025 | ["+2", 2], |
| 4026 | ["02", 2], |
| 4027 | ] as const) { |
| 4028 | assert.deepStrictEqual( |
| 4029 | windowsLongPathConfigEnv("win32", count === undefined ? {} : { GIT_CONFIG_COUNT: count }), |
| 4030 | { |
| 4031 | GIT_CONFIG_COUNT: String(next + 1), |
| 4032 | [`GIT_CONFIG_KEY_${next}`]: "core.longpaths", |
| 4033 | [`GIT_CONFIG_VALUE_${next}`]: "true", |
| 4034 | }, |
| 4035 | `GIT_CONFIG_COUNT=${JSON.stringify(count)}`, |
| 4036 | ); |
| 4037 | } |
| 4038 | }); |
| 4039 | |
| 4040 | it("leaves a count Git would reject for Git to report", () => { |
| 4041 | for (const count of ["nope", "2x", "-1", "1.5", " ", "1 "]) { |
| 4042 | assert.deepStrictEqual( |
| 4043 | windowsLongPathConfigEnv("win32", { GIT_CONFIG_COUNT: count }), |
| 4044 | {}, |
| 4045 | `GIT_CONFIG_COUNT=${JSON.stringify(count)}`, |
| 4046 | ); |
| 4047 | } |
| 4048 | }); |
| 4049 | }); |