Skip to content

Commit 9fecc4e

Browse files
committed
Make sure to run git submodule checkout in dry run mode
1 parent e05789c commit 9fecc4e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/bootstrap/src/lib.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,26 @@ impl Build {
490490
return;
491491
}
492492

493-
let submodule_git = || helpers::git(Some(&absolute_path)).capture_stdout();
493+
// Submodule updating actually happens during in the dry run mode. We need to make sure that
494+
// all the git commands below are actually executed, because some follow-up code
495+
// in bootstrap might depend on the submodules being checked out. Furthermore, not all
496+
// the command executions below work with an empty output (produced during dry run).
497+
// Therefore, all commands below are marked with `run_always()`, so that they also run in
498+
// dry run mode.
499+
let submodule_git = || {
500+
let mut cmd = helpers::git(Some(&absolute_path)).capture_stdout();
501+
cmd.run_always();
502+
cmd
503+
};
494504

495505
// Determine commit checked out in submodule.
496-
let checked_out_hash = submodule_git().args(["rev-parse", "HEAD"]).run(self).stdout();
506+
let checked_out_hash =
507+
submodule_git().run_always().args(["rev-parse", "HEAD"]).run(self).stdout();
497508
let checked_out_hash = checked_out_hash.trim_end();
498509
// Determine commit that the submodule *should* have.
499510
let recorded = helpers::git(Some(&self.src))
500511
.capture_stdout()
512+
.run_always()
501513
.args(["ls-tree", "HEAD"])
502514
.arg(relative_path)
503515
.run(self)
@@ -514,6 +526,7 @@ impl Build {
514526

515527
println!("Updating submodule {}", relative_path.display());
516528
helpers::git(Some(&self.src))
529+
.run_always()
517530
.args(["submodule", "-q", "sync"])
518531
.arg(relative_path)
519532
.run(self);
@@ -524,12 +537,14 @@ impl Build {
524537
// even though that has no relation to the upstream for the submodule.
525538
let current_branch = helpers::git(Some(&self.src))
526539
.capture_stdout()
540+
.run_always()
527541
.args(["symbolic-ref", "--short", "HEAD"])
528542
.run(self)
529543
.stdout_if_ok()
530544
.map(|s| s.trim().to_owned());
531545

532546
let mut git = helpers::git(Some(&self.src)).allow_failure();
547+
git.run_always();
533548
if let Some(branch) = current_branch {
534549
// If there is a tag named after the current branch, git will try to disambiguate by prepending `heads/` to the branch name.
535550
// This syntax isn't accepted by `branch.{branch}`. Strip it.

0 commit comments

Comments
 (0)