labeler
labeler copied to clipboard
Better document wildcard matching in README
Hello. Thanks for the labeler action. I am trying to use it to apply labels based on directories touched, however, it is unclear this alone is enough if I want everything under example
:
label1:
- example/**/*
Or I need this (based on @domain/core
example):
label1:
- example/*
- example/**/*
cc @saimn
xref astropy/astropy#10974
This is subtle. This action is using the minimatch package which in turn is using bash's semantics for how to iinterpret **
("globstar"). From man bash
:
* Matches any string, including the null string. When the
globstar shell option is enabled, and * is used in a
pathname expansion context, two adjacent *s used as a
single pattern will match all files and zero or more
directories and subdirectories. If followed by a /, two
adjacent *s will match only directories and subdirecto‐
ries.
This explains why you need both example/*
and example/**/*
. The latter case only matches directories and subdirectories (but not files) since it has **
followed by /
.
This seems sort of confusing at first glance, but actually it makes sense if you consider the example: example/**/
. Because the pattern ends in /
it implies the **
is only matching directories. So when appending to that example/**/*
it is keeping consistent with those semantics.
On the other hand, I tried it with minimatch directly and it does not appear to follow this rule:
> minimatch('example/foo.txt', 'example/**/*')
true
I am not familiar with minimatch
, but over at astropy/astropy#10974 , it seems that just example/**/*
is enough.
Hello everyone! This issue has been open for a year without any activity, so I'm going to close it as stale. Please feel free to contact us if the issue is still relevant to you and we will reopen it. Thanks!