cleanups
This commit is contained in:
parent
84d04f28c9
commit
e924aa4b7d
|
@ -16,13 +16,17 @@ func main() {
|
||||||
log.Warn("forgepb.ConfigLoad() failed", err)
|
log.Warn("forgepb.ConfigLoad() failed", err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.List {
|
if argv.List {
|
||||||
|
repos.PrintTable()
|
||||||
|
/*
|
||||||
log.Info(forgepb.RepoHeader())
|
log.Info(forgepb.RepoHeader())
|
||||||
loop := repos.SortByPath() // get the list of repos
|
loop := repos.SortByPath() // get the list of repos
|
||||||
for loop.Scan() {
|
for loop.Scan() {
|
||||||
r := loop.Repo()
|
r := loop.Repo()
|
||||||
log.Info("repo:", r.GoPath)
|
log.Info("repo:", r.GoPath)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
human.go
9
human.go
|
@ -14,12 +14,8 @@ import (
|
||||||
// so reporting tables of the status of what droplets and hypervisors
|
// so reporting tables of the status of what droplets and hypervisors
|
||||||
// are in text columns and rows that can be easily read in a terminal
|
// are in text columns and rows that can be easily read in a terminal
|
||||||
|
|
||||||
func RepoHeader() string {
|
|
||||||
return "Name Path"
|
|
||||||
}
|
|
||||||
|
|
||||||
func standardHeader() string {
|
func standardHeader() string {
|
||||||
return fmt.Sprintf("%-4s %40s %s", "r/w", "Path", "flags")
|
return fmt.Sprintf("%-4s %-40s %s", "", "Path", "flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (all *Repos) standardHeader(r *Repo) string {
|
func (all *Repos) standardHeader(r *Repo) string {
|
||||||
|
@ -28,6 +24,9 @@ func (all *Repos) standardHeader(r *Repo) string {
|
||||||
if all.IsPrivate(r.GoPath) {
|
if all.IsPrivate(r.GoPath) {
|
||||||
flags += "(private) "
|
flags += "(private) "
|
||||||
}
|
}
|
||||||
|
if all.IsFavorite(r.GoPath) {
|
||||||
|
flags += "(favorite) "
|
||||||
|
}
|
||||||
if all.IsReadOnly(r.GoPath) {
|
if all.IsReadOnly(r.GoPath) {
|
||||||
readonly = ""
|
readonly = ""
|
||||||
} else {
|
} else {
|
||||||
|
|
66
settings.go
66
settings.go
|
@ -84,6 +84,30 @@ func (all *Repos) IsReadOnly(gopath string) bool {
|
||||||
return true
|
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?
|
// is this a non-publishable repo?
|
||||||
// matches package names from apt
|
// matches package names from apt
|
||||||
//
|
//
|
||||||
|
@ -131,26 +155,36 @@ func (all *Repos) IsPrivate(thing string) bool {
|
||||||
return match.Private
|
return match.Private
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the deb package name
|
// IsFavorite() -- fun option for the config
|
||||||
// this let's you check a git tag version against a package .deb version
|
// file that lets you set things as favorites
|
||||||
// allows gopath's to not need to match the .deb name
|
// so you can just go-clone a bunch of common things
|
||||||
// this is important in lots of cases! It is normal and happens often enough.
|
// on a new box or after you reset/delete your ~/go/src dir
|
||||||
func (all *Repos) DebName(gopath string) string {
|
func (all *Repos) IsFavorite(thing string) bool {
|
||||||
// get "zookeeper" from "go.wit.com/apps/zookeeper"
|
var match *Repo
|
||||||
normalBase := filepath.Base(gopath)
|
|
||||||
|
|
||||||
loop := all.SortByPath()
|
loop := all.SortByPath() // get the list of repos
|
||||||
for loop.Scan() {
|
for loop.Scan() {
|
||||||
r := loop.Repo()
|
r := loop.Repo()
|
||||||
if r.GoPath == gopath {
|
if r.GoPath == thing {
|
||||||
// returns "zookeeper-go" for "go.wit.com/apps/zookeeper"
|
if r.Favorite {
|
||||||
if r.DebName != "" {
|
return true
|
||||||
// log.Info("FOUND DebName", r.DebName)
|
}
|
||||||
return r.DebName
|
}
|
||||||
} else {
|
base := filepath.Base(r.GoPath)
|
||||||
return normalBase
|
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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue