Skip to content

Commit

Permalink
engine: skip over symlinks (#123)
Browse files Browse the repository at this point in the history
We don't want to format files outside the directory, and if the symlink
destination is in the repo, it'll be matched when iterating over it.

Fixes #122.
  • Loading branch information
flokli authored Aug 3, 2021
1 parent 5fff9c3 commit d1bc82a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ pub fn run_treefmt(
match walk_entry {
Ok(dir_entry) => {
if let Some(file_type) = dir_entry.file_type() {
if !file_type.is_dir() {
// Ignore folders and symlinks. We don't want to format files outside the
// directory, and if the symlink destination is in the repo, it'll be matched
// when iterating over it.
if !file_type.is_dir() && !file_type.is_symlink() {
// Keep track of how many files were traversed
traversed_files += 1;

Expand Down

0 comments on commit d1bc82a

Please sign in to comment.