mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-13 07:43:09 +00:00
fix(stdin and gitignore): updated to prevent gitignore from skipping std temp paths
Disabled gitignore option for stdin paths. closes #224
This commit is contained in:
parent
1dc5a26814
commit
8e0b4b1b41
4 changed files with 33 additions and 11 deletions
|
|
@ -39,7 +39,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "node ./bin/install.js",
|
"postinstall": "node ./bin/install.js",
|
||||||
"commit": "git add . && cz"
|
"commit": "git add . && pre-commit run && git add . && cz --no-verify"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Christopher Pickering",
|
"name": "Christopher Pickering",
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
black==22.3.0; python_full_version >= "3.6.2"
|
black==22.1.0; python_full_version >= "3.6.2"
|
||||||
click==8.1.2; python_version >= "3.6"
|
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")
|
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"
|
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"
|
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")
|
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"
|
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"
|
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"
|
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")
|
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.5.3; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.6.2"
|
typed-ast==1.4.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"
|
typing-extensions==4.1.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"
|
zipp==3.7.0; python_version < "3.8" and python_version >= "3.7"
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,9 @@ def main(
|
||||||
temp_file.write(str.encode(stdin_text))
|
temp_file.write(str.encode(stdin_text))
|
||||||
temp_file.seek(0)
|
temp_file.seek(0)
|
||||||
|
|
||||||
|
# cannot use gitignore for stdin paths.
|
||||||
|
config.use_gitignore = False
|
||||||
|
|
||||||
file_list = get_src([Path(temp_file.name)], config)
|
file_list = get_src([Path(temp_file.name)], config)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,13 @@ run::
|
||||||
|
|
||||||
for a single test, 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
|
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# pylint: disable=C0116
|
# pylint: disable=C0116
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
@ -40,6 +41,7 @@ def test_cli(runner: CliRunner) -> None:
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
|
|
||||||
os.remove("tests/config_gitignore/.gitignore")
|
os.remove("tests/config_gitignore/.gitignore")
|
||||||
|
shutil.rmtree("tests/config_gitignore/.git")
|
||||||
|
|
||||||
|
|
||||||
def test_pyproject(runner: CliRunner) -> None:
|
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/.gitignore")
|
||||||
os.remove("tests/config_gitignore/pyproject.toml")
|
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='<div><p id="a"></p></div>')
|
||||||
|
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")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue