Fix includeIf case sensitivity on Windows self-hosted runners#2425
Open
Fix includeIf case sensitivity on Windows self-hosted runners#2425
Conversation
9979a83 to
c0c6be9
Compare
Contributor
There was a problem hiding this comment.
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_GITDIRprefix (includeIf.gitdir/i:on Windows,includeIf.gitdir:elsewhere). - Updates all
includeIfkey construction sites to use the new prefix. - Updates the cleanup key-regex to remove both
gitdir:andgitdir/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 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:' |
c0c6be9 to
6e134d0
Compare
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
6e134d0 to
be385d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:\Workspaceson disk vsD:\workspacesin config), theincludeIfcondition never matches and git auth silently fails.This was introduced in v6 with the move to credential isolation via
includeIf(#2286). v5 did not useincludeIfso 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 togitdir/i:on Windows while keepinggitdir:on Linux/macOS where case sensitivity is expected.Also updates the cleanup regex to handle both variants so credential removal still works.
Fixes #2345