Skip to content

Commit

Permalink
dev: initialize submodules in dev doctor
Browse files Browse the repository at this point in the history
This commit adds a check to `dev doctor` to initialize submodules, like we do
in our `Makefile`.

Release note: None
  • Loading branch information
aayushshah15 committed Feb 2, 2022
1 parent baeba80 commit 8504245
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/cmd/dev/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package main
import (
"errors"
"log"
"os"
"os/exec"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -99,6 +100,24 @@ Please perform the following steps:
}
}

const binDir = "bin"
const submodulesMarkerPath = binDir + "/.submodules-initialized"
d.log.Println("doctor: running submodules check")
if _, err := os.Stat(submodulesMarkerPath); errors.Is(err, os.ErrNotExist) {
if _, err = d.exec.CommandContextSilent(ctx, "git", "rev-parse", "--is-inside-work-tree"); err != nil {
return err
}
if _, err = d.exec.CommandContextSilent(ctx, "git", "submodule", "update", "--init", "--recursive"); err != nil {
return err
}
if err = d.os.MkdirAll(binDir); err != nil {
return err
}
if err = d.os.WriteFile(submodulesMarkerPath, ""); err != nil {
return err
}
}

// Check whether the build is properly configured to use stamping.
passedStampTest := true
if _, err := d.exec.CommandContextSilent(ctx, "bazel", "build", "//build/bazelutil:test_stamping"); err != nil {
Expand Down

0 comments on commit 8504245

Please sign in to comment.