Skip to content

Commit

Permalink
Merge pull request #23 from kurtmckee/improve-exclusion-matching
Browse files Browse the repository at this point in the history
Improve exclusion matching
  • Loading branch information
kurtmckee authored Dec 7, 2023
2 parents baf8cb6 + 70946bb commit dbe77de
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions .chipshot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ SPDX-License-Identifier: MIT
exclusions = [
"docs/conf.py",
"docs/_static/custom.css",
"tests/files/",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changed
-------

* Allow exclusions to match directories, too.
4 changes: 3 additions & 1 deletion docs/how-to/exclusions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ It supports a list of files that Chipshot must ignore.
The example below will tell Chipshot to exclude ``conf.py``,
which is the standard name for a Sphinx configuration file;
it will also ignore ``Gruntfile.js``,
which is a common name for a Grunt configuration file.
which is a common name for a Grunt configuration file;
it will also ignore everything in the ``tests/`` subdirectory.

.. code-block:: toml
[chipshot]
exclusions = [
"docs/conf.py",
"Gruntfile.js",
"tests/",
]
5 changes: 4 additions & 1 deletion src/chipshot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def _get_files(
continue

# Ensure that the path is not excluded.
if any(sub_path == exclusion for exclusion in exclusions):
if any(
sub_path == exclusion or sub_path.is_relative_to(exclusion)
for exclusion in exclusions
):
continue

yield sub_path
Expand Down
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import copy
import pathlib

Expand Down
4 changes: 4 additions & 0 deletions tests/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pytest

import chipshot.compare
Expand Down
4 changes: 4 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pytest


Expand Down
4 changes: 4 additions & 0 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pathlib

import chipshot.reader
Expand Down
4 changes: 4 additions & 0 deletions tests/test_reader_encoding.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import codecs
import logging
import pathlib
Expand Down
4 changes: 4 additions & 0 deletions tests/test_reader_header.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pathlib

import pytest
Expand Down
4 changes: 4 additions & 0 deletions tests/test_reader_identity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pathlib

import pytest
Expand Down
4 changes: 4 additions & 0 deletions tests/test_reader_newlines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pytest

import chipshot.reader.newlines
Expand Down
4 changes: 4 additions & 0 deletions tests/test_reader_prolog.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pathlib

import pytest
Expand Down
4 changes: 4 additions & 0 deletions tests/test_render.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import pathlib
import textwrap

Expand Down
4 changes: 4 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file is a part of Chipshot <https://github.com/kurtmckee/chipshot>
# Copyright 2022-2023 Kurt McKee <[email protected]>
# SPDX-License-Identifier: MIT

import codecs
import pathlib

Expand Down

0 comments on commit dbe77de

Please sign in to comment.