Skip to content

Non-English directories are skipped #603

Closed

Description

@AlekSi

Looks like pre-commit skips non-English directories. Please take a look at those:

A relevant bit from the full Travis build output:

$ pre-commit run --all-files
[…]
Trim Trailing Whitespace.................................................Failed
hookid: trailing-whitespace
Files were modified by this hook. Additional output:
Fixing public/episode/2017/04-14-096/index.html
Fixing public/episode/2016/03-31-050/index.html
[…]
Fixing public/episode/2016/09-01-072/index.html
Fixing public/episode/2015/12-29-036/index.html
The command "pre-commit run --all-files" exited with 1.

$ git status
HEAD detached at df0529b
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
	modified:   "public/categories/\320\263\320\276\321\201\321\202\320\270/index.html"
	modified:   "public/categories/\320\263\320\276\321\201\321\202\320\270/index.xml"
	modified:   "public/categories/\320\270\320\275\321\202\320\265\321\200\320\262\321\214\321\216/index.html"
	modified:   "public/categories/\320\270\320\275\321\202\320\265\321\200\320\262\321\214\321\216/index.xml"
	modified:   "public/categories/\320\270\321\202\320\276\320\263\320\270/index.html"
	modified:   "public/categories/\320\270\321\202\320\276\320\263\320\270/index.xml"
	modified:   "public/categories/\320\272\320\260\320\274\320\270\320\275/index.html"
	modified:   "public/categories/\320\272\320\260\320\274\320\270\320\275/index.xml"
	modified:   "public/categories/\320\275\320\276\320\262\320\276\321\201\321\202\320\270/index.html"
	modified:   "public/categories/\320\275\320\276\320\262\320\276\321\201\321\202\320\270/index.xml"
	modified:   public/js/highlight.pack.js
	modified:   public/page/1/index.html
no changes added to commit (use "git add" and/or "git commit -a")

Those directories in public/categories/ are гости, итоги, камин, новости, and интервью.

Activity

  1. asottile commented on Sep 5, 2017

    @asottile
    Member

    Thanks for the report! I should be able to reproduce and fix this pretty easily, let me see if there's a workaround to get you going quicker first :)

  2. asottile commented on Sep 5, 2017

    @asottile
    Member

    Ah definitely a bug! It has to do with our usage of git ls-files and should be easy to fix.

    A workaround is to bypass the bug in --all-files (though not pretty): git ls-files -z | xargs -0 pre-commit run --files

    I'll get a fix out for you asap!

  3. asottile commented on Sep 5, 2017

    @asottile
    Member

    This is fixed in 0.18.2, I'll see what I need to poke to get this into brew :)

  4. asottile commented on Sep 5, 2017

    @asottile
    Member

    womp, I don't have access to macos, I think this is the minimum necessary to get this version into brew:

    brew bump-formula-pr \
        --dry-run \
        --url=https://github.com/pre-commit/pre-commit/archive/v0.18.2.tar.gz \
        --sha256=196b1090a7e3ee80314953298ac636c566e87a014398c48e911d9a4c6599e776 \
        pre-commit
    

    (remove --dry-run if it looks correct)

  5. AlekSi commented on Sep 6, 2017

    @AlekSi
    Author

    I installed 0.18.2 (it was merged) and that's what I got:

    $ pre-commit run --all-files
    Trim Trailing Whitespace.................................................Failed
    hookid: trailing-whitespace
    
    Files were modified by this hook. Additional output:
    
    Fixing public/episode/2017/04-14-096/index.html
    Fixing public/episode/2016/03-31-050/index.html
    Fixing public/episode/2016/10-14-077/index.html
    Fixing public/episode/2015/09-10-017/index.html
    Fixing public/episode/2016/02-04-041/index.html
    Fixing public/page/4/index.html
    Fixing public/episode/2016/07-16-065/index.html
    Fixing public/episode/2017/01-18-090/index.html
    Fixing public/episode/2016/01-14-038/index.html
    Fixing public/episode/2016/01-07-037/index.html
    Fixing public/episode/2017/02-08-093/index.html
    Fixing public/page/9/index.html
    Fixing public/episode/2016/04-28-054/index.html
    Fixing public/episode/2016/11-23-084/index.html
    Fixing public/404.html
    Fixing public/episode/2015/11-26-031/index.html
    Fixing public/page/3/index.html
    Fixing public/episode/2016/06-30-063/index.html
    Fixing public/episode/2015/11-19-028/index.html
    Fixing public/episode/2016/07-29-067/index.html
    Fixing public/episode/2016/06-02-059/index.html
    Fixing public/episode/2015/07-16-006/index.html
    Fixing public/episode/2016/05-05-055/index.html
    Fixing public/about/index.html
    Fixing public/episode/2015/06-18-002/index.html
    Fixing public/episode/2015/10-15-023/index.html
    Fixing public/categories/index.xml
    Fixing public/episode/2015/08-27-014/index.html
    Fixing public/episode/2016/02-25-045/index.html
    Fixing public/episode/2015/10-22-024/index.html
    Fixing public/index.xml
    Fixing public/post/2015/09-03-before-015/index.html
    Fixing public/episode/2016/02-05-042/index.html
    Fixing public/episode/2016/06-23-062/index.html
    Fixing public/episode/2015/06-11-001/index.html
    Fixing public/online/index.html
    Traceback (most recent call last):
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/bin/trailing-whitespace-fixer", line 11, in <module>
        load_entry_point('pre-commit-hooks==0.9.1', 'console_scripts', 'trailing-whitespace-fixer')()
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/lib/python2.7/site-packages/pre_commit_hooks/trailing_whitespace_fixer.py", line 80, in fix_trailing_whitespace
        print('Fixing {}'.format(bad_whitespace_file))
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-22: ordinal not in range(128)
    Traceback (most recent call last):
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/bin/trailing-whitespace-fixer", line 11, in <module>
        load_entry_point('pre-commit-hooks==0.9.1', 'console_scripts', 'trailing-whitespace-fixer')()
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/lib/python2.7/site-packages/pre_commit_hooks/trailing_whitespace_fixer.py", line 80, in fix_trailing_whitespace
        print('Fixing {}'.format(bad_whitespace_file))
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-22: ordinal not in range(128)
    Traceback (most recent call last):
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/bin/trailing-whitespace-fixer", line 11, in <module>
        load_entry_point('pre-commit-hooks==0.9.1', 'console_scripts', 'trailing-whitespace-fixer')()
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/lib/python2.7/site-packages/pre_commit_hooks/trailing_whitespace_fixer.py", line 80, in fix_trailing_whitespace
        print('Fixing {}'.format(bad_whitespace_file))
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-24: ordinal not in range(128)
    Traceback (most recent call last):
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/bin/trailing-whitespace-fixer", line 11, in <module>
        load_entry_point('pre-commit-hooks==0.9.1', 'console_scripts', 'trailing-whitespace-fixer')()
      File "/Users/aleksi/.pre-commit/repoybD6Jg/py_env-python2.7/lib/python2.7/site-packages/pre_commit_hooks/trailing_whitespace_fixer.py", line 80, in fix_trailing_whitespace
        print('Fixing {}'.format(bad_whitespace_file))
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-24: ordinal not in range(128)
    
  6. asottile commented on Sep 6, 2017

    @asottile
    Member

    Ah yes the fun python2 "bug"

    When printing to a non-tty, python2 print() must have ascii-convertible arguments.

    A workaround would be to use language_version: python3, or I could adjust pre-commit-hooks to not use print() and instead write bytes to stdout

  7. asottile commented on Sep 6, 2017

    @asottile
    Member

    I've submitted a patch to homebrew that should prefer python3:

    Homebrew/homebrew-core#17712

  8. added a commit that references this issue on Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions