Rollup merge of #104953 - jyn514:fewer-submodule-updates, r=Mark-Simulacrum

Ensure required submodules at the same time as updating existing submodules

In practice, this would always happen at the same time, but putting them next to each other makes that more obvious and ensures it doesn't change in the future. It also avoids the difference affecting `cargo metadata` somehow.

This is based on https://github.com/rust-lang/rust/pull/104952 for convenience to avoid merge conflicts, but doesn't depend on that PR.
This commit is contained in:
Matthias Krüger 2022-12-05 20:43:42 +01:00 committed by GitHub
commit f4643f59cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -579,6 +579,8 @@ pub fn new(mut config: Config) -> Build {
for s in rust_submodules {
build.update_submodule(Path::new(s));
}
// Now, update all existing submodules.
build.update_existing_submodules();
build.verbose("learning about cargo");
metadata::build(&mut build);
@ -674,7 +676,7 @@ fn dir_is_empty(dir: &Path) -> bool {
/// If any submodule has been initialized already, sync it unconditionally.
/// This avoids contributors checking in a submodule change by accident.
pub fn maybe_update_submodules(&self) {
pub fn update_existing_submodules(&self) {
// Avoid running git when there isn't a git checkout.
if !self.config.submodules(&self.rust_info()) {
return;
@ -703,8 +705,6 @@ pub fn build(&mut self) {
job::setup(self);
}
self.maybe_update_submodules();
if let Subcommand::Format { check, paths } = &self.config.cmd {
return format::format(&builder::Builder::new(&self), *check, &paths);
}