From 784991a344f3cd27e5ddf6ae92f39def540032b3 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 6 Jul 2024 12:25:13 +0200 Subject: 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. --- main.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 } -- cgit v1.2.3-70-g09d2