summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--settings.go42
1 files changed, 33 insertions, 9 deletions
diff --git a/settings.go b/settings.go
index 0e23764..e5bc65c 100644
--- a/settings.go
+++ b/settings.go
@@ -27,6 +27,7 @@ func (all *Repos) UpdateGoPath(name string, gopath string) bool {
}
// returns true if gopath is readonly()
+// will attempt to match IsWritable("foo") against anything ending in "foo"
func (all *Repos) IsReadOnly(gopath string) bool {
var match *Repo
@@ -46,6 +47,13 @@ func (all *Repos) IsReadOnly(gopath string) bool {
return false
}
}
+ // if gopath == "foo" will return false if "go.wit.com/apps/foo" is Writable
+ base := filepath.Base(r.GoPath)
+ if base == gopath {
+ if r.Writable {
+ return false
+ }
+ }
// search for potential dir matches
if r.Directory {
// test the dir
@@ -77,7 +85,13 @@ func (all *Repos) IsReadOnly(gopath string) bool {
}
// is this a non-publishable repo?
-func (all *Repos) IsPrivate(gopath string) bool {
+// matches package names from apt
+//
+// IsPrivate("foo") will match anything in the config file ending in "foo"
+//
+// IsPrivate("go.foo.com/jcarr/foo") returns true if private
+// IsPrivate("foo") also returns true if "go.bar.com/jcarr/foo" is private
+func (all *Repos) IsPrivate(thing string) bool {
var match *Repo
// sort by path means the simple 'match' logic
@@ -86,23 +100,30 @@ func (all *Repos) IsPrivate(gopath string) bool {
loop := all.SortByPath() // get the list of repos
for loop.Scan() {
r := loop.Repo()
- if r.GoPath == gopath {
+ if r.GoPath == thing {
// if private is set here, then ok, otherwise
// still check if a Directory match exists
if r.Private {
return true
}
}
+ base := filepath.Base(r.GoPath)
+ if base == thing {
+ if r.Private {
+ return true
+ }
+ }
+ // check to see if IsPrivate("foo")
// search for potential dir matches
if r.Directory {
// test the dir
- if strings.HasPrefix(gopath, r.GoPath) {
+ if strings.HasPrefix(thing, r.GoPath) {
match = r
}
}
}
if match == nil {
- // log.Info("did not match in IsPrivate()", gopath)
+ // log.Info("did not match in IsPrivate()", thing)
return false
}
@@ -110,18 +131,21 @@ func (all *Repos) IsPrivate(gopath string) bool {
return match.Private
}
-// returns the deb package
+// 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 {
- // if private is set here, then ok, otherwise
- // still check if a Directory match exists
- if r.DebName == "" {
+ // returns "zookeeper-go" for "go.wit.com/apps/zookeeper"
+ if r.DebName != "" {
+ // log.Info("FOUND DebName", r.DebName)
return r.DebName
} else {
return normalBase