diff options
| author | Jeff Carr <[email protected]> | 2024-03-21 16:16:35 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-03-21 16:16:35 -0500 |
| commit | 2ce9051921ef1ef93b6bcaa48850f2b207b86598 (patch) | |
| tree | f2e19ffa6cef7eb4a153e01450618cca9c85ad09 | |
| parent | 804acc169a49320a5f9a0efb60847071f7fee7f2 (diff) | |
exec things to STDOUT
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | git.go | 2 | ||||
| -rw-r--r-- | gitConfig.go | 9 | ||||
| -rw-r--r-- | goList.go | 34 | ||||
| -rw-r--r-- | new.go | 3 |
4 files changed, 46 insertions, 2 deletions
@@ -298,7 +298,7 @@ func (rs *RepoStatus) CheckoutUser() bool { log.Log(REPO, rs.realPath.String(), "is dirty") return false } - if ! rs.BranchExists(bName) { + if !rs.BranchExists(bName) { return false } cmd := []string{"git", "checkout", bName} diff --git a/gitConfig.go b/gitConfig.go index abfc72a..b2c2af9 100644 --- a/gitConfig.go +++ b/gitConfig.go @@ -281,5 +281,14 @@ func (rs *RepoStatus) BranchExists(branch string) bool { log.Log(REPOWARN, rs.Path(), "found branch", branch, hash) return true } + for i, t := range rs.Tags.tags { + base := filepath.Base(t.tag.String()) + if base == branch { + log.Info("found tag:", i, t.tag.String()) + return true + } + log.Info("not tag:", i, t.tag.String()) + } + log.Log(REPOWARN, rs.Path(), "did not find branch", branch) return false } diff --git a/goList.go b/goList.go new file mode 100644 index 0000000..b49ecd2 --- /dev/null +++ b/goList.go @@ -0,0 +1,34 @@ +package repostatus + +import ( + "encoding/json" + "errors" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +// go list -json -m go.wit.com/apps/go-clone@latest + +// go list -json -m go.wit.com/apps/go-clone@latest +// { +// "Path": "go.wit.com/apps/go-clone", +// "Version": "v0.0.6", +// "Query": "latest", +// "Time": "2024-03-10T04:12:15Z", +// "GoMod": "/home/jcarr/go/pkg/mod/cache/download/go.wit.com/apps/go-clone/@v/v0.0.6.mod", +// "GoVersion": "1.22.0" +// } + +func runGoList(url string) (string, error) { + r := shell.RunPath("", []string{"go", "list", "-json", "-m", url + "@latest"}) + log.Info("runGoList() r.Output =", r.Output) + var modInfo any + err := json.Unmarshal(r.Output, &modInfo) + if err != nil { + log.Info("runGoList() json.Unmarshal() error =", err) + return "", err + } + log.Spew(modInfo) + return "", errors.New("todo: parse json") +} @@ -133,7 +133,8 @@ func Clone(wdir string, path string) error { return nil } var url string - if url, err = findGoImport("http://" + path); err != nil { + // if url, err = findGoImport("http://" + path); err != nil { + if url, err = runGoList(path); err != nil { return err } log.Info("URL:", url) |
