Running captainhook in child directory causes errors
jambonrose opened this issue · comments
When I install captainhook via pip, running captainhook run
in a child directory causes the following error.
$ # in a child directory (child of the project root)
$ pwd
project/src
$ captainhook run
Traceback (most recent call last):
File "project/.git/hooks/pre-commit", line 127, in <module>
exit_code = main(commit_only=not args.all)
File "project/.git/hooks/pre-commit", line 107, in main
errors = mod.run(files, TEMP_FOLDER)
File "project/.git/hooks/checkers/flake8_checker.py", line 39, in run
py_files = filter_python_files(files)
File "project/.git/hooks/checkers/utils.py", line 106, in filter_python_files
elif 'python' in open(f, 'r').readline():
FileNotFoundError: [Errno 2] No such file or directory: '.gitignore'
This is likely because of the command "git ls-tree --name-only --full-tree -r HEAD"
in captainhook/checkers/utils.py
.
In the development version of the code (which appears to be different?) the command fails silently.
$ git ci
===============================================================================
Checking isort
===============================================================================
--- src/test.py:before 2015-08-15 09:22:34
+++ src/test.py:after 2015-08-15 09:22:35.491702
@@ -1,5 +1,5 @@
+import os
+
import django
-import os
-
boo()
===============================================================================
Rejecting commit
===============================================================================
$ captainhook run
$ # no output!