Repository navigation
Conversation
56e79e1 to
927a10c
Compare
…nhanced pattern matching - Replaced `filepath.Glob` with `doublestar.Glob` to support advanced glob patterns (e.g., `**/*.py` for recursive matching). Signed-off-by: Yang Kaiyong <yangkaiyong.yky@antgroup.com>
…delfile Added a detailed explanation of the unix-like glob path pattern. Signed-off-by: Yang Kaiyong <yangkaiyong.yky@antgroup.com>
decb6f8 to
ea5b98e
Compare
|
Currently, the glob path in the standard library is based on the standard implementation, and most language implementations are relatively uniform. While |
aftersnow
left a comment
There was a problem hiding this comment.
Status check on the current head (ea5b98e) against today's main. Two facts have changed since the "hold off" decision in March 2025:
1. doublestar is already a dependency of main. go.mod has github.com/bmatcuk/doublestar/v4 v4.10.0, pulled in by #473, and modelfile generate --include/--exclude match with doublestar semantics. The "extra interpretation cost for users" argument now cuts the other way: the two commands disagree on what a pattern means.
2. build silently drops ** patterns today. I built this Modelfile on main (f241cec):
NAME ws99
MODEL w.safetensors
CODE src/**/*.py
with src/y.py and src/a/b/x.py present. The build succeeded and only the MODEL layer was produced; filepath.Glob treats ** as *, matched nothing, and processor/base.go does not warn when a wildcard pattern matches zero files. A user who writes ** because generate --include accepts it loses files without any error.
So I think this change is worth reviving, with three adjustments:
- Rebase onto
main. The module path is nowgithubproxy.fjygbaifeng.eu.org/modelpack/modctl,go.mod/go.sumandpkg/backend/processor/base.goall conflict, andbase.gonow has a literal-path branch (absolute paths, "file specified in Modelfile does not exist") that must stay as is; only the wildcard branch should switch todoublestar.Glob(os.DirFS(absWorkDir), pattern). - Fail or warn when a wildcard pattern matches nothing. That is the actual footgun above, independent of which glob library is used.
- Add a test with a
**pattern inpkg/backend/processor.
cc @chlins since the earlier decision was yours.
filepath.Globwithdoublestar.Globto support advanced glob patterns (e.g.,**/*.pyfor recursive matching).