Skip to content

feat(os/gfile): add MatchGlob function with globstar support (#4570)#4574

Merged
houseme merged 6 commits intomasterfrom
feat/glob
Dec 26, 2025
Merged

feat(os/gfile): add MatchGlob function with globstar support (#4570)#4574
houseme merged 6 commits intomasterfrom
feat/glob

Conversation

@hailaz
Copy link
Contributor

@hailaz hailaz commented Dec 25, 2025

This pull request introduces a new glob pattern matching utility to the gfile package, adding support for advanced glob patterns including the "**" (globstar) operator, which matches across directory boundaries, similar to bash and gitignore. It also includes a comprehensive set of unit tests to verify the correctness and cross-platform compatibility of the new functionality.

Glob pattern matching feature:

  • Added MatchGlob function to gfile, which extends filepath.Match with support for the "**" (globstar) pattern, enabling recursive directory matching and more flexible file pattern matching.
  • Implemented internal helpers (matchGlobstar and doMatchGlobstar) to handle normalization of path separators and recursive matching logic for patterns containing "**".

Testing and validation:

  • Added gfile_z_unit_match_test.go with extensive unit tests covering basic glob patterns, globstar usage, prefix/suffix combinations, multiple globstars, edge cases, and Windows path compatibility to ensure robust and cross-platform behavior.

Copilot AI review requested due to automatic review settings December 25, 2025 04:07
Copy link
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 adds a new MatchGlob function to the gfile package that extends standard glob pattern matching with support for the ** (globstar) operator, enabling recursive directory matching similar to bash globstar and gitignore patterns.

Key Changes:

  • Implemented MatchGlob function with globstar support that falls back to filepath.Match for simple patterns
  • Added internal recursive matching logic (matchGlobstar and doMatchGlobstar) to handle path normalization and globstar expansion
  • Comprehensive test suite covering basic patterns, globstar variations, edge cases, and Windows path compatibility

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
os/gfile/gfile_match.go New file implementing the MatchGlob function with globstar pattern matching support and helper functions for path normalization and recursive matching
os/gfile/gfile_z_unit_match_test.go Comprehensive unit tests covering basic glob patterns, globstar usage in various configurations, multiple globstars, edge cases, and cross-platform path handling

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

@hailaz hailaz requested a review from houseme December 26, 2025 06:58
Copy link
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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


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

@houseme houseme merged commit 90564f9 into master Dec 26, 2025
26 checks passed
@houseme houseme deleted the feat/glob branch December 26, 2025 08:37
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.

3 participants