mattlqx / pre-commit-search-and-replace

Plugin for pre-commit for arbitrary search and replace on committed files.
MIT License
12 stars 7 forks source link

Any way to exclude binary files? #1

Closed ammmze closed 5 years ago

ammmze commented 5 years ago

We've got a scenario where we have a library that talks to a git repo and part of the tests for that include a sample git repo in a tgz file. When the search-and-replace plugin runs we get the following error:

/Users/myusername/.cache/pre-commit/repomZBRdc/lib/search-and-replace.rb:58:in `index': invalid byte sequence in UTF-8 (ArgumentError)
    from /Users/myusername/.cache/pre-commit/repomZBRdc/lib/search-and-replace.rb:58:in `search_line'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/lib/search-and-replace.rb:40:in `parse_file'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/lib/search-and-replace.rb:29:in `block in parse_files'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/lib/search-and-replace.rb:29:in `map'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/lib/search-and-replace.rb:29:in `parse_files'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/bin/search-and-replace.rb:58:in `block in <main>'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/bin/search-and-replace.rb:55:in `each'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/bin/search-and-replace.rb:55:in `each_with_index'
    from /Users/myusername/.cache/pre-commit/repomZBRdc/bin/search-and-replace.rb:55:in `<main>'

i think can work around it fine by committing the tgz by itself bypassing the commit hooks and then can do the code changes with the commit hooks. But figured it would be good to support excluding files if there isn't a way currently.