Skip to content
Commit 3c62f894 authored by Luca Di Sera's avatar Luca Di Sera
Browse files

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.
parent ec63f343
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment