Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/__test__
diff options
context:
space:
mode:
authorSalman Muin Kayser Chishti <salmanmkc@GitHub.com>2026-05-06 12:17:20 +0000
committerGitHub <noreply@github.com>2026-05-06 12:27:25 +0000
commit0bb5abcdf2d394c07dfd344b0eaec4970d37bee0 (patch)
tree139a46c9beb5e3f474dcd867f16a9b61e45798d9 /__test__
parent45c7dc79a6c1ac19a6a0981f08146cb419b30891 (diff)
Fix includeIf case sensitivity on Windows self-hosted runnersfix-windows-includeif-case-sensitivity
Switch to includeIf.gitdir/i: on Windows so path matching is case-insensitive, matching the filesystem behavior. This fixes auth failures on self-hosted Windows runners where the workspace folder casing doesn't match between the runner config and disk. Also update the cleanup regex to handle both gitdir: and gitdir/i: variants. Fixes #2345
Diffstat (limited to '__test__')
-rw-r--r--__test__/git-auth-helper.test.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/__test__/git-auth-helper.test.ts b/__test__/git-auth-helper.test.ts
index ad3566a..debee46 100644
--- a/__test__/git-auth-helper.test.ts
+++ b/__test__/git-auth-helper.test.ts
@@ -974,6 +974,46 @@ describe('git-auth-helper tests', () => {
).toBe(false)
expect((authHelper as any).testCredentialsConfigPath('')).toBe(false)
})
+
+ const includeIfCleanupRegex_matchesBothVariants =
+ 'includeIf cleanup regex matches both gitdir: and gitdir/i: keys'
+ it(includeIfCleanupRegex_matchesBothVariants, async () => {
+ // The cleanup regex must match both variants so credential
+ // removal works regardless of which was written
+ const regex = /^includeIf\.gitdir(\/i)?:/
+ expect(regex.test('includeIf.gitdir:D:/workspaces/repo/.git.path')).toBe(
+ true
+ )
+ expect(regex.test('includeIf.gitdir/i:D:/Workspaces/repo/.git.path')).toBe(
+ true
+ )
+ expect(regex.test('includeIf.gitdir/i:/github/workspace/.git.path')).toBe(
+ true
+ )
+ expect(regex.test('includeIf.gitdir:~/projects/foo/.git.path')).toBe(true)
+ expect(regex.test('includeIf.onbranch:main.path')).toBe(false)
+ expect(regex.test('include.path')).toBe(false)
+ })
+
+ const includeIfDirective_usesCorrectVariantForPlatform =
+ 'includeIf directive uses gitdir/i on Windows and gitdir on other platforms'
+ it(includeIfDirective_usesCorrectVariantForPlatform, async () => {
+ await setup(includeIfDirective_usesCorrectVariantForPlatform)
+ const authHelper = gitAuthHelper.createAuthHelper(git, settings)
+ await authHelper.configureAuth()
+
+ const localConfigContent = (
+ await fs.promises.readFile(localGitConfigPath)
+ ).toString()
+
+ if (isWindows) {
+ expect(localConfigContent).toContain('includeIf.gitdir/i:')
+ expect(localConfigContent).not.toContain('includeIf.gitdir:')
+ } else {
+ expect(localConfigContent).toContain('includeIf.gitdir:')
+ expect(localConfigContent).not.toContain('includeIf.gitdir/i:')
+ }
+ })
})
async function setup(testName: string): Promise<void> {