Skip to content

Match a glob token made only of **/ segments [patch] - #182

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/181-globstar-only-token
Nov 4, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/181-globstar-only-token

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #181

What was wrong

ExpandGlobStarSegments expands a bare **/ both as */ and as the empty string. Glob.Parse("") throws, so ResolveGlob's catch marked the whole token unparseable and discarded the valid */ expansion with it. Under the unparseable-token rules, **/ then matched every item and -**/ ("hide directories") hid nothing.

Change

ResolveGlob drops empty expansions before calling Glob.Parse. An empty pattern could only match empty text, which never reaches the matcher. If nothing is left afterwards, the token is still treated as unparseable, as before.

Tests

  • GlobTokenOfOnlyGlobStarSlashMatchesItemsEndingInSeparator (**/, **/**/) returns only docs/
  • GlobExcludedTokenOfOnlyGlobStarSlashHidesItemsEndingInSeparator (-**/, -**/**/) hides docs/
  • GlobRequiredTokenOfOnlyGlobStarSlashMatchesOnlyItemsEndingInSeparator (+**/)

All five cases fail on main (I reverted the fix to confirm) and pass with it. The full suite passes: 218/218, including the existing **/ tests from #114, #126, #135 and #170.

The triage comment says to land this after #171. The two change different methods (ResolveGlob here, ExpandGlobStarSegments there), so a textual conflict is unlikely.


Generated by Claude Code

ExpandGlobStarSegments expands a bare "**/" both as "*/" and as the empty
string. Glob.Parse throws on the empty pattern, so ResolveGlob marked the whole
token unparseable and threw away the valid "*/" expansion: "**/" matched every
item and "-**/" hid nothing. Drop empty expansions before parsing, and still
treat a token with nothing left as unparseable.

Fixes #181

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW4QsgMfJRhwEBdboKd
@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 5f420d9 into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/181-globstar-only-token branch November 4, 2026 00:59
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.

A glob token made only of **/ segments is treated as unparseable: **/ matches every item and -**/ hides nothing

2 participants