From 94b81decc63636c5803314e8c9787846cd132378 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 26 Sep 2025 23:44:05 -0500 Subject: using FullPath finally --- main.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/main.go b/main.go index 34094ba..99f75e6 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "os" - "strings" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/forgepb" @@ -24,13 +23,14 @@ var forge *forgepb.Forge var configSave bool func main() { - auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg // this line must be before anything else + auto = prep.Bash(&argv) // add support for bash autocomplete with go-arg // this line must be before anything else log.Info("go-mod-clean version", VERSION, "built on", BUILDTIME) forge = forgepb.Init() // figure out what directory we are running in - check := findPwdRepo() + pwd, _ := os.Getwd() + check := forge.Repos.FindByFullPath(pwd) if check == nil { log.Info("this directory isn't in a golang project (not in ~/go/src nor a go.work file)") badExit(nil, nil) @@ -76,21 +76,24 @@ func main() { } func findPwdRepo() *gitpb.Repo { - var check *gitpb.Repo + // var check *gitpb.Repo // attempt to use the working directory // this is probably what happens most of the time pwd, _ := os.Getwd() - if strings.HasPrefix(pwd, forge.Config.ReposDir) { - gopath := strings.TrimPrefix(pwd, forge.Config.ReposDir) - gopath = strings.Trim(gopath, "/") - check = forge.FindByGoPath(gopath) - if check != nil { - log.Info(check.Namespace, "was found ok in forge") - return check + return forge.Repos.FindByFullPath(pwd) + /* + if strings.HasPrefix(pwd, forge.Config.ReposDir) { + gopath := strings.TrimPrefix(pwd, forge.Config.ReposDir) + gopath = strings.Trim(gopath, "/") + check = forge.FindByGoPath(gopath) + if check != nil { + log.Info(check.Namespace, "was found ok in forge") + return check + } } - } - log.Info("findRepo() forge could not find GO path:", pwd) - return nil + log.Info("findRepo() forge could not find GO path:", pwd) + return nil + */ } func saveAsMetadata(repo *gitpb.Repo) error { -- cgit v1.2.3