// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "errors" "fmt" "path/filepath" "go.wit.com/lib/env" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) func doCleanNamespace(r *gitpb.Repo) error { // check for GO repos gowork := env.Get("gopath") // todo: detect if using go.work file newpath, err := filepath.Rel(gowork, r.FullPath) if err != nil { log.Info("cleanNamespace got err", newpath, err) // check for other stuff. use the URLs return err } if newpath == r.Namespace { // namespace was already set right return nil } r.Namespace = newpath err = errors.New("namepace changed") s := fmt.Sprintf("old(%s), new(%s)", r.Namespace, newpath) return errors.Join(errors.New(s), err) } // checks to see if the r.Namespace seems right func doVerifyNamespace() (string, error) { fixed := me.forge.RunOnRepos(me.forge.Repos, doCleanNamespace) if fixed.Len() != 0 { fixed = fixed.SortActual() footer := me.forge.PrintDefaultTB(fixed) me.forge.Repos.SaveVerbose() return "changed namespaces: " + footer, nil } return "no namespaces changed", nil }