Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: ignore folders that look like yaml files. #257

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/yamlfix/entrypoints/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _find_all_yaml_files(
file
for list_ in files
for file in list_
if not _matches_any_glob(file, dir_, exclude_globs)
if not _matches_any_glob(file, dir_, exclude_globs) and os.path.isfile(file)
]


Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path
from textwrap import dedent

import py # type: ignore
import pytest
from _pytest.logging import LogCaptureFixture
from click.testing import CliRunner
Expand Down Expand Up @@ -410,3 +411,12 @@ def test_std_and_file_error(runner: CliRunner, tmp_path: Path) -> None:
assert (
str(result.exception) == "Cannot specify '-' and other files at the same time."
)


def test_do_not_read_folders_as_files(runner: CliRunner, tmpdir: py.path.local) -> None:
"""Skips folders that have a .yml or .yaml extension."""
tmpdir.mkdir("folder.yml")

result = runner.invoke(cli, [str(tmpdir)])

assert result.exit_code == 0