Skip to content

Ignore All The Things! - v1.0.0-rc.2

Latest
Compare
Choose a tag to compare
@TekWizely TekWizely released this 31 Jul 21:53
bf2137d

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/file would attempt to match patterns against the directory foo/bar
  • Patterns with leading slash (/) indicate that the pattern is anchored and must match the beginning of the directory path
    • Pattern /bar would match filenames bar/file and bar/bang/file, but not foo/bar/file
  • Patterns without leading slash (/) indicate that the pattern is floating and can match anywhere in the directory path
    • Pattern bar would match all filenames bar/file, bar/bang/file and foo/bar/file
  • 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.txt would match filenames file.txt, foo/file.txt, and bar/file.txt
  • Patterns with leading slash (/) indicate that the pattern is anchored and must match the full file path
    • Pattern /bar/file would match filename bar/file, but not foo/bar/file
  • Patterns without leading slash (/) indicate that the pattern is trailing and just needs to match the end of the file path
    • Pattern bar/file would match filenames bar/file and foo/bar/file
  • 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 extglob setting/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.