Ignore All The Things! - v1.0.0-rc.2
Full Changelog: v1.0.0-rc.1...v1.0.0-rc.2
Release v1.0.0-rc.2
Passing Ignore Patterns To Hooks
You can pass arguments to hooks to specify files / directories to ignore.
Ignoring Directories
To specify a directory to ignore, use:
--hook:ignore-dir=PATTERN
Pattern Syntax
Here's a table with examples of how the directory ignore patterns work:
| (see legend below) | /foo |
/foo/bar |
/foo/*/bar |
bar |
bing/bar |
bing/*/bar |
foo/*/bang/*/bar |
|---|---|---|---|---|---|---|---|
file |
|||||||
foo/file |
✔ | ||||||
foo/bar/file |
✔ | ✔ | ✔ | ||||
foo/bing/bar/file |
✔ | ✔ | ✔ | ✔ | |||
foo/bing/bang/bar/file |
✔ | ✔ | ✔ | ✔ | |||
foo/bing/bang/baz/bar/file |
✔ | ✔ | ✔ | ✔ | ✔ | ||
bar/file |
✔ | ||||||
bing/bar/file |
✔ | ✔ | |||||
bing/bang/bar/file |
✔ | ✔ |
rows = filenames. columns = ignore patterns. ✔ = directory ignored (matched).
NOTES:
- Only the directory portion of the filename is considered for matching
- File
foo/bar/filewould attempt to match patterns against the directoryfoo/bar
- File
- Patterns with leading slash (
/) indicate that the pattern is anchored and must match the beginning of the directory path- Pattern
/barwould match filenamesbar/fileandbar/bang/file, but notfoo/bar/file
- Pattern
- Patterns without leading slash (
/) indicate that the pattern is floating and can match anywhere in the directory path- Pattern
barwould match all filenamesbar/file,bar/bang/fileandfoo/bar/file
- Pattern
- Trailing slashes (
foo/) are not supported and are ignored - Explicit Leading and trailing wildcards (
*/foo,foo/*,*/foo/*) are not supported - Recursive directory patterns (
**) are not supported
Ignoring Files
To specify files to ignore, use:
--hook:ignore-file=PATTERN
Pattern Syntax
Here's a table with examples of how the file ignore patterns work:
| (see legend below) | file1.txt |
file?.txt |
file2.* |
*.md |
bar/*.md |
/bar/*.txt |
|---|---|---|---|---|---|---|
file1.txt |
✔ | ✔ | ||||
file2.txt |
✔ | ✔ | ||||
file3.md |
✔ | |||||
foo/file1.txt |
✔ | ✔ | ||||
bar/file1.txt |
✔ | ✔ | ✔ | |||
bar/file2.md |
✔ | ✔ | ✔ | |||
foo/bar/file4.txt |
✔ | |||||
foo/bar/file5.md |
✔ | ✔ |
rows = filenames. columns = ignore patterns. ✔ = file ignored (matched).
NOTES:
- Patterns with no slashes (
/) are only matched against the filename portion of the file path- Pattern
file.txtwould match filenamesfile.txt,foo/file.txt, andbar/file.txt
- Pattern
- Patterns with leading slash (
/) indicate that the pattern is anchored and must match the full file path- Pattern
/bar/filewould match filenamebar/file, but notfoo/bar/file
- Pattern
- Patterns without leading slash (
/) indicate that the pattern is trailing and just needs to match the end of the file path- Pattern
bar/filewould match filenamesbar/fileandfoo/bar/file
- Pattern
- Explicit Leading (
*/foo/file) are not supported - Recursive directory patterns (
**) are not supported
Ignore By Pattern
If the directory and file-based convenience options are not enough, you can specify a more complicated (bash-specific) pattern.
To specify these types of patterns to ignore, use:
--hook:ignore-pattern=PATTERN
Pattern Syntax
Here's a table with examples of how the general ignore patterns work:
| (see legend below) | file |
foo/bar/* |
foo/*/bar/* |
*/file |
*/bar/file |
*/bar/* |
*/bing/*/bar/* |
*/b?ng/*/file |
|---|---|---|---|---|---|---|---|---|
file |
✔ | |||||||
foo/file |
✔ | |||||||
foo/bar/file |
✔ | ✔ | ✔ | ✔ | ||||
foo/bing/bar/file |
✔ | ✔ | ✔ | ✔ | ✔ | |||
foo/bang/bar/file |
✔ | ✔ | ✔ | ✔ | ✔ | |||
foo/bing/bang/bar/file |
✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ||
foo/bing/bang/baz/bar/file |
✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ||
bar/file |
✔ | |||||||
bing/bar/file |
✔ | ✔ | ✔ | |||||
bing/bang/bar/file |
✔ | ✔ | ✔ | ✔ | ||||
.file |
||||||||
.bar/file |
✔ | |||||||
foo/.bang/bar/file |
✔ | ✔ | ✔ | ✔ |
rows = filenames. columns = ignore patterns. ✔ = file ignored (matched).
NOTES:
- Patterns are matched against the full (relative) file path
- Patterns are Bash-specific (although possibly POSIX compliant) and are not regular expressions (regex)
- See the Official Bash documentation for Pattern Matching
- Patterns based on
extglobsetting/syntax are not supported
Nearing Official v1.0.0 Release
There are 3 features I'd like to have implemented before declaring an official v.1.0.0 release:
- Passing Environment Variables to Hooks (#27)
- Passing Ignore Patterns to Hooks (#38)
- Passing Repo / File Directory Values to Commands
With 2 of these down, I can start to focus on the 3rd, which already has some progress (#32)
Please feel free to chime in if you have some ideas or use cases for this type of feature.