From 0bb5abcdf2d394c07dfd344b0eaec4970d37bee0 Mon Sep 17 00:00:00 2001 From: Salman Muin Kayser Chishti Date: Wed, 6 May 2026 12:17:20 +0000 Subject: 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 --- src/git-auth-helper.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index e67db14..8d2eb91 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -13,6 +13,12 @@ import {IGitCommandManager} from './git-command-manager' import {IGitSourceSettings} from './git-source-settings' const IS_WINDOWS = process.platform === 'win32' +// Use case-insensitive gitdir matching on Windows to handle path casing mismatches +// between the runner's GITHUB_WORKSPACE and the actual filesystem casing. +// See: https://github.com/actions/checkout/issues/2345 +const INCLUDE_IF_GITDIR = IS_WINDOWS + ? 'includeIf.gitdir/i:' + : 'includeIf.gitdir:' const SSH_COMMAND_KEY = 'core.sshCommand' export interface IGitAuthHelper { @@ -182,7 +188,7 @@ class GitAuthHelper { // Configure host includeIf await this.git.config( - `includeIf.gitdir:${submoduleGitDir}.path`, + `${INCLUDE_IF_GITDIR}${submoduleGitDir}.path`, credentialsConfigPath, false, // globalConfig? false, // add? @@ -204,7 +210,7 @@ class GitAuthHelper { // Configure container includeIf await this.git.config( - `includeIf.gitdir:${containerSubmoduleGitDir}.path`, + `${INCLUDE_IF_GITDIR}${containerSubmoduleGitDir}.path`, containerCredentialsPath, false, // globalConfig? false, // add? @@ -371,11 +377,11 @@ class GitAuthHelper { gitDir = gitDir.replace(/\\/g, '/') // Use forward slashes, even on Windows // Configure host includeIf - const hostIncludeKey = `includeIf.gitdir:${gitDir}.path` + const hostIncludeKey = `${INCLUDE_IF_GITDIR}${gitDir}.path` await this.git.config(hostIncludeKey, credentialsConfigPath) // Configure host includeIf for worktrees - const hostWorktreeIncludeKey = `includeIf.gitdir:${gitDir}/worktrees/*.path` + const hostWorktreeIncludeKey = `${INCLUDE_IF_GITDIR}${gitDir}/worktrees/*.path` await this.git.config(hostWorktreeIncludeKey, credentialsConfigPath) // Container git directory @@ -397,11 +403,11 @@ class GitAuthHelper { ) // Configure container includeIf - const containerIncludeKey = `includeIf.gitdir:${containerGitDir}.path` + const containerIncludeKey = `${INCLUDE_IF_GITDIR}${containerGitDir}.path` await this.git.config(containerIncludeKey, containerCredentialsPath) // Configure container includeIf for worktrees - const containerWorktreeIncludeKey = `includeIf.gitdir:${containerGitDir}/worktrees/*.path` + const containerWorktreeIncludeKey = `${INCLUDE_IF_GITDIR}${containerGitDir}/worktrees/*.path` await this.git.config( containerWorktreeIncludeKey, containerCredentialsPath @@ -554,7 +560,7 @@ class GitAuthHelper { try { // Get all includeIf.gitdir keys const keys = await this.git.tryGetConfigKeys( - '^includeIf\\.gitdir:', + '^includeIf\\.gitdir(/i)?:', false, // globalConfig? configPath ) -- cgit v1.2.3