Support patterns starting with ** in ignore files#952
Conversation
mtrmac
left a comment
There was a problem hiding this comment.
I don’t know that much about this code…. but is this that much of a special case? I’d expect p.compile() to handle this, from a very quick glance.
Also the ContainsAny(…, "*?[]") check makes me suspicious. If **.md is supposed to work, why not **.[Cc]++? And if the latter is supposed to work, the current code would still expect p.compile() handle it; isn’t it easier to do it that way only?
This is a special case in Docker. https://github.com/moby/patternmatcher/blob/main/patternmatcher.go#L388 If the line begins with two asterisks and what follows does not contain the characters a) anything that has what is after a) currently does not work, we treat
In docker's code, there are multiple But maybe it would be better to do the docker-style detection in Or other idea would be to just write to documentation that
It is for us to decide whether this is special enough for us to include it as an exception. Docker parses the line, determines a mode and then matches based on the mode. Podman does not have any modes and just interprets everything as regex. |
|
@nalind what do you think? What would be a reasonable resolution of the issue? |
Those were not [documented to be] intended as “different semantics”; moby/patternmatcher@2d3e837 added them as a performance optimization. AFAICT https://docs.docker.com/build/concepts/context/#matching documents that So all in all I think this is really just a bug in Docker. moby/patternmatcher#12, let’s see what happens. |
That’s a good reason to look for a way for a split a function… [1]
… but… the split must make sense. The way I think about it, “what does this function do (and when it is used)” is a question that should have a fairly simple answer. Every extra condition or special case “it does everything correctly except if …, in that case call something else” is a smell indicating that there probably is a somewhat different function boundary that allows expressing the function’s purpose in a simpler way, or that probably there is a different way to document that function boundary. [1] “does too many things” is subtly different is “is long an tediously does one clearly delineated thing in many steps”. |
Ultimately, we do aim for comparable behavior - it's why we added the carveout for an exact prefix match when we did. I, too, would have guessed that it would be incorporated into the pattern-to-regexp transformation. I'd want to see where that issue in pattermatcher goes to determine if this behavior is something to be caught up with, or to be corrected. |
Fixes: podman-container-tools/buildah#6417 Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
fee0995 to
e97e740
Compare
|
Okay, thanks for feedback. We'll see what happens in the issue, but for now I updated the code so that |
Fixes: podman-container-tools/buildah#6417