gittuf
gittuf copied to clipboard
Wildcard in rule pattern doesn't apply to subdirectories
What happened?
gittuf currently uses glob-style patterns. This means that file:foo/*
will apply to all files in the foo/ directory but not in the foo/bar/ directory. The glob-style patterns are based off the upstream TUF specification but they're not ideal for gittuf. Instead, I propose we switch our patterns to align with gitignore. This should be a drop-in replacement. Note that with this change, file:foo/*
will still not match other /
, but we can at least support file:foo/**
.
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Thinking aloud, but I think what we really want is just fnmatch? No need of ** then, fnmatch doesn't special case directory separaters. It operates strictly on strings as well.
So what would the behavior be in this case then?
I think fnmatch would meet the original expectation trivially. No need for **
, *
would match /
supporting subdirectories as well.
What if you don't want to match subdirectories? Is that use case important?
On Wed, Feb 28, 2024 at 2:00 PM Aditya Sirish @.***> wrote:
I think fnmatch would meet the original expectation trivially. No need for **, * would match / supporting subdirectories as well.
— Reply to this email directly, view it on GitHub https://github.com/gittuf/gittuf/issues/309#issuecomment-1969652272, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGRODZS5BHQP26V5MESQI3YV55FDAVCNFSM6AAAAABDXKMET2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRZGY2TEMRXGI . You are receiving this because you commented.Message ID: @.***>
Do you mean where foo
has three subdirectories a
, b
, c
and you want a pattern to only apply to a
and b
and not c
? fnmatch doesn't make this trivial (regex may be a better option here but I don't know if we want the complexity of regex). I want to note though that you could support this by explicitly defining a terminating rule for foo/c
and then include a rule for foo/*
. Either way, you're explicitly declaring the subdirectory you do not want to match.