feat: Add the ability to have some file extensions *prevent* a module from triggering (#4043)

* test that we can match a multi-part file extension such as in foo.tar.gz

* now we can match multi-part file extensions like on foo.tar.gz

* add a test that a !ext is a negative match and over-rides any positive match

* test that negative extensions that don't match any file have no effect

* fail the match if any negative extensions exist

* cargo fmt

I'm not happy with this, in particular it's made the structures of has_any_positive_extension and has_no_negative_extension look different, and the logic in is_match is harder to follow

* placate clippy

* documentation for multi-part extensions and negative extensions

* get rid of an unnecessary .to_string() and comment the necessary but weird-looking invocations of .to_string_lossy().to_string()

* tests for negative matching of files and folders

* fail the match is any negative files/folders match

* document file/folder negative matching; be less prolix

* suppress Nodejs if Deno files are present (#2627)

* Revert "suppress Nodejs if Deno files are present (#2627)"

This reverts commit c1394fd7b3.

This was a terrible way of doing this, there's got to be a better way!
This commit is contained in:
David Cantrell
2022-07-31 15:29:48 +01:00
committed by GitHub
parent b75677ab59
commit dd73447329
3 changed files with 124 additions and 13 deletions
+18
View File
@@ -152,6 +152,24 @@ format = '''
\$'''
```
### Negative matching
Many modules have `detect_extensions`, `detect_files`, and `detect_folders` variables. These take
lists of strings to match or not match. "Negative" options, those which should not be matched, are
indicated with a leading "!" character. The presence of _any_ negative indicator in the directory
will result in the module not being matched.
Extensions are matched against both the characters after the last dot in a filename, and the
characters after the first dot in a filename. For example, `foo.bar.tar.gz` will be matched
against `bar.tar.gz` and `gz` in the `detect_extensions` variable. Files whose name begins with a
dot are not considered to have extensions at all.
To see how this works in practice, you could match TypeScript but not MPEG Transport Stream files thus:
```toml
detect_extensions = ["ts", "!video.ts", "!audio.ts"]
```
## Prompt
This is the list of prompt-wide configuration options.