diff --git a/package.json b/package.json index bb2d6e0..5b54eef 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ }, "scripts": { "postinstall": "node ./bin/install.js", - "commit": "git add . && cz" + "commit": "git add . && pre-commit run && git add . && cz --no-verify" }, "author": { "name": "Christopher Pickering", diff --git a/requirements.txt b/requirements.txt index 50c913c..f24dedb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,16 @@ -black==22.3.0; python_full_version >= "3.6.2" -click==8.1.2; python_version >= "3.6" +black==22.1.0; python_full_version >= "3.6.2" +click==8.0.3; python_version >= "3.6" colorama==0.4.4; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -importlib-metadata==4.11.3; python_version >= "3.7" +importlib-metadata==4.11.0; python_version >= "3.7" isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0" mypy-extensions==0.4.3; python_full_version >= "3.6.2" pathspec==0.9.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -platformdirs==2.5.2; python_version >= "3.7" and python_full_version >= "3.6.2" +platformdirs==2.5.0; python_version >= "3.7" and python_full_version >= "3.6.2" pyyaml==6.0; python_version >= "3.6" -regex==2022.3.15 +regex==2022.1.18 tomli==2.0.1; python_version >= "3.7" and python_full_version >= "3.6.2" tomlkit==0.10.1; python_version >= "3.6" and python_version < "4.0" -tqdm==4.64.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") -typed-ast==1.5.3; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.6.2" -typing-extensions==4.2.0; python_version < "3.8" and python_version >= "3.7" and python_full_version >= "3.6.2" -zipp==3.8.0; python_version < "3.8" and python_version >= "3.7" +tqdm==4.62.3; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") +typed-ast==1.4.3; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.6.2" +typing-extensions==4.1.0; python_version < "3.8" and python_version >= "3.7" and python_full_version >= "3.6.2" +zipp==3.7.0; python_version < "3.8" and python_version >= "3.7" diff --git a/src/djlint/__init__.py b/src/djlint/__init__.py index 7e7b879..6b4ab1e 100644 --- a/src/djlint/__init__.py +++ b/src/djlint/__init__.py @@ -135,6 +135,9 @@ def main( temp_file.write(str.encode(stdin_text)) temp_file.seek(0) + # cannot use gitignore for stdin paths. + config.use_gitignore = False + file_list = get_src([Path(temp_file.name)], config) else: diff --git a/tests/test_config_gitignore.py b/tests/test_config_gitignore.py index 1288287..9bb1f70 100644 --- a/tests/test_config_gitignore.py +++ b/tests/test_config_gitignore.py @@ -7,12 +7,13 @@ run:: for a single test, run:: - pytest tests/test_config_gitignore.py::test_pyproject --cov=src/djlint \ + pytest tests/test_config_gitignore.py::test_ignored_path --cov=src/djlint \ --cov-branch --cov-report xml:coverage.xml --cov-report term-missing """ # pylint: disable=C0116 import os +import shutil from pathlib import Path from click.testing import CliRunner @@ -40,6 +41,7 @@ def test_cli(runner: CliRunner) -> None: assert result.exit_code == 1 os.remove("tests/config_gitignore/.gitignore") + shutil.rmtree("tests/config_gitignore/.git") def test_pyproject(runner: CliRunner) -> None: @@ -73,3 +75,20 @@ def test_pyproject(runner: CliRunner) -> None: os.remove("tests/config_gitignore/.gitignore") os.remove("tests/config_gitignore/pyproject.toml") + shutil.rmtree("tests/config_gitignore/.git") + +def test_ignored_path(runner: CliRunner) -> None: + # test for https://github.com/Riverside-Healthcare/djLint/issues/224 + # create .git folder to make root + Path("tests/config_gitignore/.git").mkdir(parents=True, exist_ok=True) + # add a gitignore file + with open("tests/config_gitignore/.gitignore", "w") as git: + git.write("var") + + result = runner.invoke(djlint, ["-", "--use-gitignore"], input='

') + print(result.output) + assert result.exit_code == 0 + assert "Linted 1 file" in result.output + + os.remove("tests/config_gitignore/.gitignore") + shutil.rmtree("tests/config_gitignore/.git")