Make sure to run git submodule checkout in dry run mode · rust-lang/rust@7a54117 (original) (raw)

`@@ -490,14 +490,25 @@ impl Build {

`

490

490

`return;

`

491

491

`}

`

492

492

``

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

`+

};

`

494

504

``

495

505

`// Determine commit checked out in submodule.

`

496

506

`let checked_out_hash = submodule_git().args(["rev-parse", "HEAD"]).run(self).stdout();

`

497

507

`let checked_out_hash = checked_out_hash.trim_end();

`

498

508

`// Determine commit that the submodule should have.

`

499

509

`let recorded = helpers::git(Some(&self.src))

`

500

510

`.capture_stdout()

`

``

511

`+

.run_always()

`

501

512

`.args(["ls-tree", "HEAD"])

`

502

513

`.arg(relative_path)

`

503

514

`.run(self)

`

`@@ -514,6 +525,7 @@ impl Build {

`

514

525

``

515

526

`println!("Updating submodule {}", relative_path.display());

`

516

527

` helpers::git(Some(&self.src))

`

``

528

`+

.run_always()

`

517

529

`.args(["submodule", "-q", "sync"])

`

518

530

`.arg(relative_path)

`

519

531

`.run(self);

`

`@@ -524,12 +536,14 @@ impl Build {

`

524

536

`// even though that has no relation to the upstream for the submodule.

`

525

537

`let current_branch = helpers::git(Some(&self.src))

`

526

538

`.capture_stdout()

`

``

539

`+

.run_always()

`

527

540

`.args(["symbolic-ref", "--short", "HEAD"])

`

528

541

`.run(self)

`

529

542

`.stdout_if_ok()

`

530

543

`.map(|s| s.trim().to_owned());

`

531

544

``

532

545

`let mut git = helpers::git(Some(&self.src)).allow_failure();

`

``

546

`+

git.run_always();

`

533

547

`if let Some(branch) = current_branch {

`

534

548

`` // If there is a tag named after the current branch, git will try to disambiguate by prepending heads/ to the branch name.

``

535

549

`` // This syntax isn't accepted by branch.{branch}. Strip it.

``