Compare commits

...

8 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 1cd929181f Apply eslint auto-fix formatting to windows-path-matching test
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
2025-12-11 14:03:26 +00:00
copilot-swe-agent[bot] f4d818c7a2 Remove unused 'path' import from windows-path-matching test
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
2025-12-11 10:12:06 +00:00
copilot-swe-agent[bot] 9de8f6f5c3 Refactor: Extract convertToMinimatchPath helper to eliminate code duplication
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
2025-12-11 09:49:13 +00:00
copilot-swe-agent[bot] a60e6db920 Address code review feedback: replace deprecated substr() with substring()
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
2025-12-10 23:36:01 +00:00
copilot-swe-agent[bot] c050f7bc2e Add Windows-specific tests for path matching with backslashes
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
2025-12-10 23:33:20 +00:00
copilot-swe-agent[bot] 0483fce47e Fix glob pattern matching on Windows by converting paths to forward slashes
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
2025-12-10 23:31:29 +00:00
copilot-swe-agent[bot] 92cb8ef23c Initial investigation of glob Windows issue
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
2025-12-10 23:28:52 +00:00
copilot-swe-agent[bot] 5d702dc7bd Initial plan 2025-12-10 23:24:11 +00:00
3 changed files with 104 additions and 1 deletions
+1
View File
@@ -5,3 +5,4 @@ packages/*/__tests__/_temp/
.DS_Store
*.xar
packages/*/audit.json
.nx/
@@ -0,0 +1,83 @@
/**
* Test to validate that glob works correctly on Windows with backslash paths
* This test validates the fix for glob not working on GitHub's Windows runners
*/
import {MatchKind} from '../src/internal-match-kind'
import {Pattern} from '../src/internal-pattern'
const IS_WINDOWS = process.platform === 'win32'
describe('Windows path matching', () => {
it('matches paths with backslashes on Windows', () => {
if (!IS_WINDOWS) {
// This test is only relevant on Windows
return
}
// Test basic pattern matching with Windows paths
const pattern = new Pattern('C:\\Users\\test\\*')
// The itemPath would come from fs.readdir with backslashes on Windows
const itemPath = 'C:\\Users\\test\\file.txt'
// This should match because the pattern and path both refer to the same file
expect(pattern.match(itemPath)).toBe(MatchKind.All)
})
it('partial matches work with backslashes on Windows', () => {
if (!IS_WINDOWS) {
return
}
// Test partial matching with Windows paths
const pattern = new Pattern('C:\\Users\\test\\**')
// Should partially match parent directory
expect(pattern.partialMatch('C:\\Users')).toBe(true)
expect(pattern.partialMatch('C:\\Users\\test')).toBe(true)
})
it('matches globstar patterns with backslashes on Windows', () => {
if (!IS_WINDOWS) {
return
}
const pattern = new Pattern('C:\\foo\\**')
// Should match the directory itself and descendants
expect(pattern.match('C:\\foo')).toBe(MatchKind.All)
expect(pattern.match('C:\\foo\\bar')).toBe(MatchKind.All)
expect(pattern.match('C:\\foo\\bar\\baz.txt')).toBe(MatchKind.All)
})
it('matches wildcard patterns with mixed separators on Windows', () => {
if (!IS_WINDOWS) {
return
}
// Pattern might be specified with forward slashes by user
const pattern = new Pattern('C:/Users/*/file.txt')
// But the actual path from filesystem will have backslashes
expect(pattern.match('C:\\Users\\test\\file.txt')).toBe(MatchKind.All)
})
it('handles complex patterns with backslashes on Windows', () => {
if (!IS_WINDOWS) {
return
}
const currentDrive = process.cwd().substring(0, 2)
const pattern = new Pattern(`${currentDrive}\\**\\*.txt`)
// Should match .txt files at any depth
expect(pattern.match(`${currentDrive}\\file.txt`)).toBe(MatchKind.All)
expect(pattern.match(`${currentDrive}\\foo\\bar\\test.txt`)).toBe(
MatchKind.All
)
expect(pattern.match(`${currentDrive}\\foo\\bar\\test.js`)).toBe(
MatchKind.None
)
})
})
+20 -1
View File
@@ -156,6 +156,10 @@ export class Pattern {
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath)
}
// Convert to forward slashes on Windows before matching with minimatch
// since the pattern was converted to forward slashes in the constructor
itemPath = Pattern.convertToMinimatchPath(itemPath)
// Match
if (this.minimatch.match(itemPath)) {
return this.trailingSeparator ? MatchKind.Directory : MatchKind.All
@@ -176,8 +180,11 @@ export class Pattern {
return this.rootRegExp.test(itemPath)
}
// Convert to forward slashes on Windows to match the pattern format used by minimatch
itemPath = Pattern.convertToMinimatchPath(itemPath)
return this.minimatch.matchOne(
itemPath.split(IS_WINDOWS ? /\\+/ : /\/+/),
itemPath.split(/\/+/),
this.minimatch.set[0],
true
)
@@ -193,6 +200,18 @@ export class Pattern {
.replace(/\*/g, '[*]') // escape '*'
}
/**
* Converts path to forward slashes on Windows for compatibility with minimatch.
* On Windows, minimatch patterns use forward slashes, so paths must be converted
* to match the same format.
*/
private static convertToMinimatchPath(itemPath: string): string {
if (IS_WINDOWS) {
return itemPath.replace(/\\/g, '/')
}
return itemPath
}
/**
* Normalizes slashes and ensures absolute root
*/