2024-12-03 01:56:58 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
2024-12-03 03:51:40 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-12-03 01:56:58 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func repomap() {
|
|
|
|
var changed bool = false
|
|
|
|
if argv.Repomap == "" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
data, _ := os.ReadFile(argv.Repomap)
|
|
|
|
|
|
|
|
for _, line := range strings.Split(string(data), "\n") {
|
|
|
|
if line == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(line, "#") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
parts := strings.Fields(line)
|
|
|
|
gopath := parts[0]
|
|
|
|
url := "https://" + parts[1]
|
|
|
|
var comment string
|
|
|
|
if len(parts) > 1 {
|
|
|
|
comment = strings.Join(parts[2:], " ")
|
|
|
|
}
|
|
|
|
repo := me.forge.Repos.FindByGoPath(gopath)
|
|
|
|
if repo == nil {
|
|
|
|
if argv.Clone {
|
2024-12-03 03:51:40 -06:00
|
|
|
cmd := []string{"go-clone", "--recursive", gopath}
|
|
|
|
shell.RunRealtime(cmd)
|
|
|
|
// me.forge.Clone(gopath)
|
2024-12-03 01:56:58 -06:00
|
|
|
} else {
|
|
|
|
log.Info(gopath, "need to clone")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if repo.URL != url {
|
|
|
|
log.Info(gopath, "url wrong", repo.URL, "vs", url)
|
|
|
|
log.Info("\tcomment", comment)
|
|
|
|
repo.URL = url
|
|
|
|
changed = true
|
|
|
|
}
|
|
|
|
if repo.Desc != comment && !(comment == "") {
|
|
|
|
log.Info(gopath, "comment wrong", repo.Desc, "vs", comment)
|
|
|
|
repo.Desc = comment
|
|
|
|
changed = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if changed {
|
|
|
|
me.forge.Repos.ConfigSave()
|
|
|
|
log.Info("config saved")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
}
|