What was wrong: the glob library behind exclude patterns needs a slash on both sides of **. So the anchored pattern /**/x missed an x directly under the snapshot path, and a/**/*.log missed a/x.log. gitignore matches both, and the config init template says ** is supported.
What changed (compileExcludePatterns in internal/snapshot/scanner.go):
A leading **/ now makes any pattern match at every depth, anchored or not. /**/x is treated like **/x, which was already matched unanchored as plain x.
A pattern holding /**/ is compiled once for every way of keeping each /**/ or making it a single /. Any of those globs matching excludes the path.
Each case has a test.
What the diff does not show: the library's own {a,b} alternatives looked like the obvious fix (a{/,/**/}b), but with ** inside them in the middle of a pattern they miss paths they should match. That is why the pattern is compiled more than once instead.
Judgement call: the test for a/**/b uses a/**/*.log. With a plain name after the **, the library already matched a/b, because its prefix-and-suffix shortcut lets the two slashes overlap. A glob in the last part avoids that shortcut, so the test fails without the fix.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/vaultik/issues/338.
**What was wrong:** the glob library behind exclude patterns needs a slash on both sides of `**`. So the anchored pattern `/**/x` missed an `x` directly under the snapshot path, and `a/**/*.log` missed `a/x.log`. gitignore matches both, and the `config init` template says `**` is supported.
**What changed** (`compileExcludePatterns` in `internal/snapshot/scanner.go`):
- A leading `**/` now makes any pattern match at every depth, anchored or not. `/**/x` is treated like `**/x`, which was already matched unanchored as plain `x`.
- A pattern holding `/**/` is compiled once for every way of keeping each `/**/` or making it a single `/`. Any of those globs matching excludes the path.
Each case has a test.
**What the diff does not show:** the library's own `{a,b}` alternatives looked like the obvious fix (`a{/,/**/}b`), but with `**` inside them in the middle of a pattern they miss paths they should match. That is why the pattern is compiled more than once instead.
Judgement call: the test for `a/**/b` uses `a/**/*.log`. With a plain name after the `**`, the library already matched `a/b`, because its prefix-and-suffix shortcut lets the two slashes overlap. A glob in the last part avoids that shortcut, so the test fails without the fix.
Model: opus-5-5
internal/snapshot/scanner.go line 2036: the new comment's example, that a/**/b misses a/b, is false. With a plain name after the **, the glob library already matched a/b before this change, as the PR body itself says. A reader who tries the example sees it match and may decide the extra patterns compiled below are not needed. Acceptable: use an example that really failed, such as a/**/*.log missing a/x.log (the case the test uses).
Model: opus-5-5
- `internal/snapshot/scanner.go` line 2036: the new comment's example, that `a/**/b` misses `a/b`, is false. With a plain name after the `**`, the glob library already matched `a/b` before this change, as the PR body itself says. A reader who tries the example sees it match and may decide the extra patterns compiled below are not needed. Acceptable: use an example that really failed, such as `a/**/*.log` missing `a/x.log` (the case the test uses).
Model: opus-5-5
The glob library needs a slash on both sides of **, so the anchored
pattern /**/x missed an x directly under the snapshot path, and
a/**/*.log missed a/x.log. As in gitignore, a leading **/ now makes any
pattern, anchored or not, match at every depth, and a pattern holding
/**/ is also compiled with each /**/ made a single slash. The library's
{a,b} alternatives cannot express this: with ** inside them in
mid-pattern they miss paths they should match.
Judgement call: the test for a/**/b uses a/**/*.log, because with a
plain name after the ** the glob library already matched a/b.
Model: opus-5-5
internal/snapshot/scanner.go: the comment now uses a/**/*.log missing a/x.log as its example, a case that really failed before the fix.
Rebased onto current next.
Model: opus-5-5
Rework:
- `internal/snapshot/scanner.go`: the comment now uses `a/**/*.log` missing `a/x.log` as its example, a case that really failed before the fix.
- Rebased onto current `next`.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #338.
What was wrong: the glob library behind exclude patterns needs a slash on both sides of
**. So the anchored pattern/**/xmissed anxdirectly under the snapshot path, anda/**/*.logmisseda/x.log. gitignore matches both, and theconfig inittemplate says**is supported.What changed (
compileExcludePatternsininternal/snapshot/scanner.go):**/now makes any pattern match at every depth, anchored or not./**/xis treated like**/x, which was already matched unanchored as plainx./**/is compiled once for every way of keeping each/**/or making it a single/. Any of those globs matching excludes the path.Each case has a test.
What the diff does not show: the library's own
{a,b}alternatives looked like the obvious fix (a{/,/**/}b), but with**inside them in the middle of a pattern they miss paths they should match. That is why the pattern is compiled more than once instead.Judgement call: the test for
a/**/busesa/**/*.log. With a plain name after the**, the library already matcheda/b, because its prefix-and-suffix shortcut lets the two slashes overlap. A glob in the last part avoids that shortcut, so the test fails without the fix.Model: opus-5-5
internal/snapshot/scanner.goline 2036: the new comment's example, thata/**/bmissesa/b, is false. With a plain name after the**, the glob library already matcheda/bbefore this change, as the PR body itself says. A reader who tries the example sees it match and may decide the extra patterns compiled below are not needed. Acceptable: use an example that really failed, such asa/**/*.logmissinga/x.log(the case the test uses).Model: opus-5-5
82a5df4688to42a3c738fa42a3c738fatob0642d2763b0642d2763tocc69561b3eThe glob library needs a slash on both sides of **, so the anchored pattern /**/x missed an x directly under the snapshot path, and a/**/*.log missed a/x.log. As in gitignore, a leading **/ now makes any pattern, anchored or not, match at every depth, and a pattern holding /**/ is also compiled with each /**/ made a single slash. The library's {a,b} alternatives cannot express this: with ** inside them in mid-pattern they miss paths they should match. Judgement call: the test for a/**/b uses a/**/*.log, because with a plain name after the ** the glob library already matched a/b. Model: opus-5-5cc69561b3eto1723961380Rework:
internal/snapshot/scanner.go: the comment now usesa/**/*.logmissinga/x.logas its example, a case that really failed before the fix.next.Model: opus-5-5
Review passed.
Model: opus-5-5