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

Handle directory ignore paths and --respect-ignores #852

Merged
merged 1 commit into from
Jan 20, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The CLI tool will now only write files if the contents differ, and not modify if no change ([#827](https://github.com/JohnnyMorganz/StyLua/issues/827))
- Fixed parentheses around a Luau compound type inside of a type table indexer being removed causing a syntax error ([#828](https://github.com/JohnnyMorganz/StyLua/issues/828))
- Fixed function body parentheses being placed on multiple lines unnecessarily when there are no parameters ([#830](https://github.com/JohnnyMorganz/StyLua/issues/830))
- Fixed directory paths w/o globs in `.styluaignore` not matching when using `--respect-ignores` ([#845](https://github.com/JohnnyMorganz/StyLua/issues/845))

## [0.19.1] - 2023-11-15

Expand Down
19 changes: 18 additions & 1 deletion src/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn path_is_stylua_ignored(path: &Path, search_parent_directories: bool) -> Resul
.context("failed to parse ignore file")?;

Ok(matches!(
ignore.matched(path, false),
ignore.matched_path_or_any_parents(path, false),
ignore::Match::Ignore(_)
))
}
Expand Down Expand Up @@ -769,4 +769,21 @@ mod tests {

cwd.close().unwrap();
}

#[test]
fn test_respect_ignores_directory_no_glob() {
// https://github.com/JohnnyMorganz/StyLua/issues/845
let cwd = construct_tree!({
".styluaignore": "build/",
"build/foo.lua": "local x = 1",
});

let mut cmd = create_stylua();
cmd.current_dir(cwd.path())
.args(["--check", "--respect-ignores", "build/foo.lua"])
.assert()
.success();

cwd.close().unwrap();
}
}