mirror of
https://github.com/actions/checkout.git
synced 2026-05-07 01:12:50 +08:00
Fix includeIf case sensitivity on Windows self-hosted runners
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
This commit is contained in:
committed by
GitHub
parent
900f2210b1
commit
be385d8fff
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user