Skip to content

Cap a whole-segment run of stars at ** in glob filters [patch] - #206

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/whole-segment-star-run-205
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/whole-segment-star-run-205

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #205

What was wrong

CollapseJoinedGlobStars collapsed a joined run of stars to * but kept a whole-segment run at full length. ***/ stayed ***/, so ExpandGlobStarSegments found ** at offset 1 and left a stray * joined to it, and DotNet.Glob matched nothing. ***/x.cs, ***/b and a/***/c matched nothing (and -***/tmp excluded nothing), while ****/b happened to work because it splits into two clean **.

Change

A whole-segment run is now capped at two stars (Math.Min(runLength, 2)), as the issue suggests. The comment above the method now says so.

Tests

  • New WholeSegmentStarRunMatchesLikeGlobStar: the issue's cases, plus runs of 4 and 5, zero-segment forms (x.cs vs ***/x.cs, a/c vs a/***/c) and the joined ***x.cs control.
  • New WholeSegmentStarRunStillRequiresTheLiteral and WholeSegmentStarRunExclusionExcludesItems (-***/tmp).
  • New CollapseJoinedGlobStarsLeavesWholeSegmentsAndClasses rows: ***/x.cs → **/x.cs, a/*****/c → a/**/c, *** → **, and x[***] left as a class.
  • With the fix reverted, 12 of the new cases fail. With it, the full suite passes on Linux / .NET 10: 353/353.

Generated by Claude Code

A whole-segment run of three or more stars (`***/x.cs`, `a/***/c`) was kept
at full length, so ExpandGlobStarSegments left a stray joined star in front
of `**` and the pattern matched nothing. Odd runs failed while even runs
happened to split into clean `**` segments. Cap the run at two stars.

Fixes #205

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

Copy link
Copy Markdown
Contributor Author

ci / .NET / Test on macos-latest is red, but not because of this PR. The test step passed (353/353 on macOS arm64), and so did the coverage upload. The job then failed in setup-dotnet's post-job cleanup: dotnet nuget locals all --list exited with code 137, which means the process was killed. This diff doesn't touch that step, and no fix for it exists in this repository. I'll re-run the failed job once, after the rest of the run finishes.


Generated by Claude Code

@sonarqubecloud

Copy link
Copy Markdown

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 whole-segment run of three stars matches nothing: glob ***/x.cs misses "a/x.cs" and "x.cs", while */x.cs, **/x.cs and ****/x.cs match

2 participants