summaryrefslogtreecommitdiff
path: root/findConfig.go
blob: 34c8f188fb70ce33e917ae7356e6a34d52e44d20 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main

import "go.wit.com/log"

func findPrivate() {
	repos := me.forge.Repos.SortByGoPath()
	for repos.Scan() {
		repo := repos.Next()
		if me.forge.Config.IsPrivate(repo.GoPath) {
			me.found.AppendUniqueGoPath(repo)
		}
	}
}

// finds repos that are writable
func findMine() {
	log.Printf("get mine %s\n", me.forge.GetGoSrc())
	repos := me.forge.Repos.SortByGoPath()
	for repos.Scan() {
		repo := repos.Next()
		if me.forge.Config.IsWritable(repo.GoPath) {
			me.found.AppendUniqueGoPath(repo)
		}
	}
}

// finds repos that are writable
func findFavorites() {
	log.Printf("get mine %s\n", me.forge.GetGoSrc())
	repos := me.forge.Repos.SortByGoPath()
	for repos.Scan() {
		repo := repos.Next()
		if me.forge.Config.IsFavorite(repo.GoPath) {
			me.found.AppendUniqueGoPath(repo)
		}
	}
}

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

	return true
}

// 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
		}
	}
}