summaryrefslogtreecommitdiff
path: root/repomap.go
blob: f41e637ca8cafbf02d2b7afcd953d3006f7545e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main

import (
	"os"
	"strings"

	"go.wit.com/lib/gui/shell"
	"go.wit.com/log"
)

//
// go-clone everything from a gowebd repomap file (go.wit.com has examples)
//

func repomap(filename string) {
	log.DaemonMode(true)

	data, err := os.ReadFile(argv.RepoMap)
	if err != nil {
		log.Info("open repomap failed", err)
		return
	}

	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.FindByGoPath(gopath)
		var cmd []string
		if argv.Recursive {
			cmd = []string{"go-clone", "--recursive", gopath}
		} else {
			cmd = []string{"go-clone", gopath}
		}
		if repo == nil {
			if argv.DryRun {
				log.Info("run:", cmd)
			} else {
				shell.RunRealtime(cmd)
			}
		} else {
			log.Info("already ran:", cmd)
		}
	}
}