Skip to content

Fix includeIf case sensitivity on Windows self-hosted runners#2425

Open
salmanmkc wants to merge 1 commit intomainfrom
fix-windows-includeif-case-sensitivity
Open

Fix includeIf case sensitivity on Windows self-hosted runners#2425
salmanmkc wants to merge 1 commit intomainfrom
fix-windows-includeif-case-sensitivity

Conversation

@salmanmkc
Copy link
Copy Markdown
Contributor

@salmanmkc salmanmkc commented May 6, 2026

On Windows, includeIf.gitdir: does case-sensitive path matching even though the filesystem is case-insensitive. When a self-hosted Windows runner has a pre-existing workspace folder with different casing than what the runner config specifies (e.g. D:\Workspaces on disk vs D:\workspaces in config), the includeIf condition never matches and git auth silently fails.

This was introduced in v6 with the move to credential isolation via includeIf (#2286). v5 did not use includeIf so it was never an issue. GitHub-hosted runners are not affected since they use a lowercase workspace folder.

Git already has a case-insensitive variant: gitdir/i: (available since 2.13.0, well before our minimum of 2.18). This PR switches to gitdir/i: on Windows while keeping gitdir: on Linux/macOS where case sensitivity is expected.

Also updates the cleanup regex to handle both variants so credential removal still works.

Fixes #2345

Copilot AI review requested due to automatic review settings May 6, 2026 12:17
@salmanmkc salmanmkc force-pushed the fix-windows-includeif-case-sensitivity branch from 9979a83 to c0c6be9 Compare May 6, 2026 12:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Windows-only regression where includeIf.gitdir: path matching is case-sensitive, causing credential include rules to fail when GITHUB_WORKSPACE casing differs from the on-disk path casing. It does so by using Git’s case-insensitive gitdir/i: condition on Windows while keeping existing behavior on other platforms.

Changes:

  • Introduces a platform-dependent INCLUDE_IF_GITDIR prefix (includeIf.gitdir/i: on Windows, includeIf.gitdir: elsewhere).
  • Updates all includeIf key construction sites to use the new prefix.
  • Updates the cleanup key-regex to remove both gitdir: and gitdir/i: includeIf entries.
Show a summary per file
File Description
src/git-auth-helper.ts Adds a Windows-specific includeIf.gitdir/i: prefix and broadens cleanup matching to handle both variants.
dist/index.js Regenerates the bundled output to reflect the TypeScript source changes.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/2 changed files
  • Comments generated: 1

Comment thread src/git-auth-helper.ts
Comment on lines 15 to +20
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:'
@salmanmkc salmanmkc changed the title Use case-insensitive includeIf.gitdir on Windows Fix includeIf case sensitivity on Windows self-hosted runners May 6, 2026
@salmanmkc salmanmkc force-pushed the fix-windows-includeif-case-sensitivity branch from c0c6be9 to 6e134d0 Compare May 6, 2026 12:22
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
@salmanmkc salmanmkc force-pushed the fix-windows-includeif-case-sensitivity branch from 6e134d0 to be385d8 Compare May 6, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forced case sensitivity on Windows based runners

2 participants