Make tidy not traverse untracked directories#112921
Make tidy not traverse untracked directories#112921Milo123459 wants to merge 1 commit intorust-lang:masterfrom Milo123459:milo/make-tidy-ignore-untracked
Conversation
|
r? @clubby789 (rustbot has picked a reviewer for you, use r? to override) |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
I don't think we want to be running this command on every invocation of |
| String::from_utf8_lossy(&output.stdout).split('\n').into_iter().collect(); | ||
| for line in stdout { | ||
| if skip.contains(&line) { | ||
| skip.remove(skip.iter().position(|x| **x = line)) |
There was a problem hiding this comment.
Shouldn't this just add each line of stdout to skip?
There was a problem hiding this comment.
The issue (unless I'm interpreting it wrong) says that you need to remove these elements from the skip array. But, that could be wrong.
There was a problem hiding this comment.
The fix for this is probably to run
git ls-files . --exclude-standard --othersand skip files that it outputs in the default filter_dirs function
The existing skip array defines directories that we wish to skip. We want to extend this with any untracked directories - all directories in skip are tracked, so right now this wouldn't do anything even without the compile errors
| "vendor", | ||
| ]; | ||
| let command = | ||
| Command::new("git").args(["ls-files", ".", "--exclude-standard", "--others"]).output(); |
There was a problem hiding this comment.
This won't work properly if tidy is run from a subdirectory. Maybe this could be combined with git rev-parse --show-toplevel?
There was a problem hiding this comment.
Also, ls-files will return each untracked file in a directory rather than the directory itself. I think --directory is the flag you want to prevent recursing into untracked dirs
There was a problem hiding this comment.
This was the command that was posted in the linked issue, so I wasn't sure. I'll look into it.
| Command::new("git").args(["ls-files", ".", "--exclude-standard", "--others"]).output(); | ||
| if let Ok(output) = command { | ||
| let stdout: Vec<&str> = | ||
| String::from_utf8_lossy(&output.stdout).split('\n').into_iter().collect(); |
There was a problem hiding this comment.
nit: no need to collect when you iterate over it below
I think in that case, if done in a OnceLock, would it not be beneficial to just put the entire array in a const or something? |
|
Untracked directories can't be known at compile time, as they may change after tidy is compiled. |
|
☔ The latest upstream changes (presumably #113370) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@Milo123459 any updates on this? |
|
dont have the time for this pr rn, sorry |
Fixes #69291
(untested, still needs some work)
Not sure if this is the best way to do it either. Could anyone give some advice?