summaryrefslogtreecommitdiff
path: root/findConfig.go
blob: efe6ee286c106c8102595707e8b0086c107fe4fd (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
51
52
53
54
55
package main

import "go.wit.com/log"

// retuns true if nothing was done
func findConfig() bool {
	var done bool = false
	if argv.FindMine {
		findConfigMine()
		done = true
	}
	if argv.FindAll {
		findConfigAll()
		done = true
	}
	if !done {
		findConfigAll()
		done = true
	}
	return done
}

// finds config repos that are writable
func findConfigMine() {
	loop := me.forge.Config.SortByGoPath()
	for loop.Scan() {
		r := loop.Next()
		gopath := r.GoPath
		if r.GetDirectory() {
			continue
		}
		if me.forge.Config.IsWritable(gopath) {
			log.Info("mine:", gopath)
			me.foundPaths = append(me.foundPaths, gopath)
			continue
		}
	}
}

// get everything in your config
func findConfigAll() {
	loop := me.forge.Config.SortByGoPath()
	for loop.Scan() {
		r := loop.Next()
		gopath := r.GoPath
		if r.GetDirectory() {
			continue
		}
		if me.forge.Config.IsWritable(gopath) {
			log.Info("mine:", gopath)
			me.foundPaths = append(me.foundPaths, gopath)
			continue
		}
	}
}