Extends git_hook to allow for a user-specified configuration file.
The behavior of the `git_hook` function was to search for a configuration file
by starting from the directory containing the first staged file and moving
upwards until a configuration file was found or a certain number of directories
were checked.
If the project configuration file is not stored in a directory that is a parent
to each python file in the codebase, the `git_hook` function was unable to
retrieve the file.
For example, this might happen with a configuration such as the following:
```
git-root/
config/
.isort.cfg
src/
...
```
To allow for the `git_hook` function to support those project structures without
breaking backwards compatibility, an optional argument, `settings_file`, was
added to it.
When `settings_file` is the empty string the function behaves as before.
Otherwise, `settings_file` is considered a path to a valid configuration file
that will be used for the hook's run.
A test in `tests/test_hooks.py` was added to cover for this case.
`README.md#Git hook` was modified to mention the new interface.
Loading
Please register or sign in to comment