summaryrefslogtreecommitdiff
path: root/doVerify.go
diff options
context:
space:
mode:
Diffstat (limited to 'doVerify.go')
-rw-r--r--doVerify.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/doVerify.go b/doVerify.go
index 79231f7..90e65c2 100644
--- a/doVerify.go
+++ b/doVerify.go
@@ -4,8 +4,9 @@
package main
import (
- "strings"
+ "path/filepath"
+ "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@@ -24,15 +25,35 @@ func doVerify() (string, error) {
return s, err
}
+func cleanNamespace(r *gitpb.Repo) string {
+ // check for GO repos
+ gowork := me.forge.Config.ReposDir
+ // todo: detect if using go.work file
+ newpath, err := filepath.Rel(gowork, r.FullPath)
+ if err != nil {
+ // relative path to gosrc or gowork is the namespace
+ return newpath
+ }
+ // check for other stuff. use the URLs
+ return ""
+}
+
// checks to see if the r.Namespace seems right
func doVerifyNamespace() (string, error) {
var s string = "doVerifyNamespace()"
var err error
+ var changed bool
for r := range me.forge.Repos.IterAll() {
- if strings.HasPrefix(r.FullPath, r.Namespace) {
- log.Info("look at:", r.FullPath, r.Namespace)
+ newpath := cleanNamespace(r)
+ if newpath != "" && newpath != r.Namespace {
+ log.Info("Changed", r.FullPath, "to", r.Namespace)
+ r.Namespace = newpath
}
}
+ if changed {
+ me.forge.Repos.SaveVerbose()
+ }
+
return s, err
}