summaryrefslogtreecommitdiff
path: root/settings.go
diff options
context:
space:
mode:
Diffstat (limited to 'settings.go')
-rw-r--r--settings.go66
1 files changed, 50 insertions, 16 deletions
diff --git a/settings.go b/settings.go
index e5bc65c..f40bdb4 100644
--- a/settings.go
+++ b/settings.go
@@ -84,6 +84,30 @@ func (all *Repos) IsReadOnly(gopath string) bool {
return true
}
+// returns the deb package name
+// this let's you check a git tag version against a package .deb version
+// allows gopath's to not need to match the .deb name
+// this is important in lots of cases! It is normal and happens often enough.
+func (all *Repos) DebName(gopath string) string {
+ // get "zookeeper" from "go.wit.com/apps/zookeeper"
+ normalBase := filepath.Base(gopath)
+
+ loop := all.SortByPath()
+ for loop.Scan() {
+ r := loop.Repo()
+ if r.GoPath == gopath {
+ // returns "zookeeper-go" for "go.wit.com/apps/zookeeper"
+ if r.DebName != "" {
+ // log.Info("FOUND DebName", r.DebName)
+ return r.DebName
+ } else {
+ return normalBase
+ }
+ }
+ }
+ return normalBase
+}
+
// is this a non-publishable repo?
// matches package names from apt
//
@@ -131,26 +155,36 @@ func (all *Repos) IsPrivate(thing string) bool {
return match.Private
}
-// returns the deb package name
-// this let's you check a git tag version against a package .deb version
-// allows gopath's to not need to match the .deb name
-// this is important in lots of cases! It is normal and happens often enough.
-func (all *Repos) DebName(gopath string) string {
- // get "zookeeper" from "go.wit.com/apps/zookeeper"
- normalBase := filepath.Base(gopath)
+// IsFavorite() -- fun option for the config
+// file that lets you set things as favorites
+// so you can just go-clone a bunch of common things
+// on a new box or after you reset/delete your ~/go/src dir
+func (all *Repos) IsFavorite(thing string) bool {
+ var match *Repo
- loop := all.SortByPath()
+ loop := all.SortByPath() // get the list of repos
for loop.Scan() {
r := loop.Repo()
- if r.GoPath == gopath {
- // returns "zookeeper-go" for "go.wit.com/apps/zookeeper"
- if r.DebName != "" {
- // log.Info("FOUND DebName", r.DebName)
- return r.DebName
- } else {
- return normalBase
+ if r.GoPath == thing {
+ if r.Favorite {
+ return true
+ }
+ }
+ base := filepath.Base(r.GoPath)
+ if base == thing {
+ if r.Favorite {
+ return true
+ }
+ }
+ if r.Directory {
+ if strings.HasPrefix(thing, r.GoPath) {
+ match = r
}
}
}
- return normalBase
+ if match == nil {
+ return false
+ }
+
+ return match.Favorite
}