diff options
Diffstat (limited to 'doClone.go')
| -rw-r--r-- | doClone.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/doClone.go b/doClone.go new file mode 100644 index 0000000..528edd0 --- /dev/null +++ b/doClone.go @@ -0,0 +1,61 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "strings" + + "go.wit.com/lib/config" + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +// +// go-clone everything from wit +// + +func doClone() error { + initForge() + + data, err := resources.ReadFile("resources/repomap") + if err != nil { + log.Info("open repomap failed", err) + return err + } + if len(data) == 0 { + log.Info("resources/repomap is empty") + return config.ErrEmpty + } + + for _, line := range strings.Split(string(data), "\n") { + if line == "" { + continue + } + if strings.HasPrefix(line, "#") { + continue + } + parts := strings.Fields(line) + gopath := parts[0] + repo := me.forge.Repos.FindByNamespace(gopath) + if repo != nil { + if argv.Verbose { + log.Info("already have", repo.FullPath) + } + continue + } + var cmd []string + cmd = []string{"go-clone", "--non-recursive", gopath} + if argv.DryRun { + log.Info("run:", cmd) + } else { + log.Info("should run:", cmd) + if _, err := shell.RunRealtimeError(cmd); err != nil { + if !argv.Force { + badExit(err) + } + } + } + } + return nil +} |
