-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Make tidy not traverse untracked directories #112921
Make tidy not traverse untracked directories #112921
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this just add each line of stdout to skip
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix for this is probably to run
git ls-files . --exclude-standard --others
and 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
@@ -31,6 +32,17 @@ pub fn filter_dirs(path: &Path) -> bool { | |||
"src/bootstrap/target", | |||
"vendor", | |||
]; | |||
let command = | |||
Command::new("git").args(["ls-files", ".", "--exclude-standard", "--others"]).output(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?