summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-07-06 12:25:13 +0200
committerxengineering <me@xengineering.eu>2024-07-06 12:25:13 +0200
commit784991a344f3cd27e5ddf6ae92f39def540032b3 (patch)
tree3298fe5dbf5e8bed679cd6d657e07dda759ae07c
parentac426d988737f3a6161c93767b4801243998e8c7 (diff)
downloadcraft-784991a344f3cd27e5ddf6ae92f39def540032b3.tar
craft-784991a344f3cd27e5ddf6ae92f39def540032b3.tar.zst
craft-784991a344f3cd27e5ddf6ae92f39def540032b3.zip
Implement recursive submodule update
This adds support for repositories having submodules. Nevertheless all the required clone operations are complete which makes this process time consuming depending on the list of submodules.
-rw-r--r--main.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/main.go b/main.go
index 86b689d..9020aaa 100644
--- a/main.go
+++ b/main.go
@@ -36,9 +36,12 @@ func main() {
}
}
-func runCommand(name string, args ...string) {
+func runCommand(dir string, name string, args ...string) {
log.Printf("%s %s\n", name, strings.Join(args, " "))
command := exec.Command(name, args...)
+ command.Dir = dir
+ command.Stderr = os.Stderr
+ command.Stdout = os.Stdout
err := command.Run()
if err != nil {
log.Fatal(err)
@@ -53,6 +56,7 @@ func prepareWorkbench(repo string, commit string) string {
defer os.RemoveAll(workbench)
runCommand(
+ workbench,
"git",
"clone",
repo,
@@ -60,6 +64,7 @@ func prepareWorkbench(repo string, commit string) string {
)
runCommand(
+ workbench,
"git",
"--git-dir",
filepath.Join(workbench, ".git"),
@@ -69,6 +74,19 @@ func prepareWorkbench(repo string, commit string) string {
commit,
)
+ runCommand(
+ workbench,
+ "git",
+ "--git-dir",
+ filepath.Join(workbench, ".git"),
+ "--work-tree",
+ workbench,
+ "submodule",
+ "update",
+ "--init",
+ "--recursive",
+ )
+
return workbench
}