Skip to content

Fix cross-platform path separator handling in gitignore pattern matching #120

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

Gitignore pattern matching fails in Linux dev container environments because Get-GitIgnorePatterns uses hardcoded Windows backslash (\) separators instead of platform-appropriate separators.

Problem

When running Validate-MarkdownFrontmatter.ps1 in the Ubuntu-based dev container, gitignore patterns like node_modules/ are converted to *\node_modules\* which never matches Linux file paths like /workspace/node_modules/....

Root Cause

  • Get-GitIgnorePatterns in LintingHelpers.psm1 hardcodes backslash separators
  • PowerShell's -like operator performs literal string matching
  • Linux paths use forward slashes, so patterns with backslashes never match

Solution

  1. Use [System.IO.Path]::DirectorySeparatorChar for platform detection
  2. Normalize input patterns by replacing both / and \ with the platform separator
  3. Refactor Validate-MarkdownFrontmatter.ps1 to use the shared helper function (DRY principle)

Files Affected

  • scripts/linting/Modules/LintingHelpers.psm1 - Update Get-GitIgnorePatterns function
  • scripts/linting/Validate-MarkdownFrontmatter.ps1 - Replace inline parsing with shared function call

Acceptance Criteria

  • node_modules/ directory is properly excluded when running in Linux dev container
  • All gitignore patterns work correctly on both Windows and Linux
  • No regression for Windows environments
  • Duplicate inline code eliminated

Metadata

Metadata

Labels

bugSomething isn't workingdevcontainerDevelopment container configuration

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions