diff options
author | xengineering <me@xengineering.eu> | 2024-07-06 12:25:13 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-07-06 12:25:13 +0200 |
commit | 784991a344f3cd27e5ddf6ae92f39def540032b3 (patch) | |
tree | 3298fe5dbf5e8bed679cd6d657e07dda759ae07c | |
parent | ac426d988737f3a6161c93767b4801243998e8c7 (diff) | |
download | craft-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.go | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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 } |