Skip to content

Commit

Permalink
Handle directory ignore paths and --respect-ignores (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMorganz committed Jan 20, 2024
1 parent bc3ce88 commit bad9530
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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();
}
}

0 comments on commit bad9530

Please sign in to comment.