-
Notifications
You must be signed in to change notification settings - Fork 13.5k
tidy: add support for --extra-checks=auto:
feature
#143398
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
base: master
Are you sure you want to change the base?
Changes from all commits
e6d537a
4da1ba7
969987c
5a88fb1
9cd9097
7b64d93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -124,6 +124,36 @@ pub fn git_diff<S: AsRef<OsStr>>(base_commit: &str, extra_arg: S) -> Option<Stri | |||
Some(String::from_utf8_lossy(&output.stdout).into()) | ||||
} | ||||
|
||||
/// Returns true if any modified file matches the predicate, if we are in CI, or if unable to list modified files. | ||||
pub fn files_modified(ci_info: &CiInfo, pred: impl Fn(&str) -> bool) -> bool { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This functions starts looking like rust/src/build_helper/src/git.rs Line 261 in c720f49
Maybe reuse it? And drop git_diff too. |
||||
let Some(base_commit) = &ci_info.base_commit else { | ||||
eprintln!("No base commit, assuming all files are modified"); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we panic here if we're on CI? This wuold be a serious issue if the commit was missing for some reason, we shouldn't just skip it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, let's just return |
||||
return true; | ||||
}; | ||||
match crate::git_diff(&base_commit, "--name-status") { | ||||
Some(output) => { | ||||
let modified_files = output.lines().filter_map(|ln| { | ||||
let (status, name) = ln | ||||
.trim_end() | ||||
.split_once('\t') | ||||
.expect("bad format from `git diff --name-status`"); | ||||
if status == "M" { Some(name) } else { None } | ||||
}); | ||||
for modified_file in modified_files { | ||||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
if pred(modified_file) { | ||||
return true; | ||||
} | ||||
} | ||||
false | ||||
} | ||||
None => { | ||||
eprintln!("warning: failed to run `git diff` to check for changes"); | ||||
eprintln!("warning: assuming all files are modified"); | ||||
true | ||||
} | ||||
} | ||||
} | ||||
|
||||
pub mod alphabetical; | ||||
pub mod bins; | ||||
pub mod debug_artifacts; | ||||
|
Uh oh!
There was an error while loading. Please reload this page.