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 avoiding `cargo metadata` somehow.
This commit is contained in:
Joshua Nelson 2022-11-26 16:11:07 -05:00
parent b771d901f7
commit ab89c171bd

View file

@ -579,6 +579,8 @@ impl 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);
@ -660,7 +662,7 @@ impl Build {
/// 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;
@ -689,8 +691,6 @@ impl Build {
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);
}