From 408a400e93acb1087079e19b9d5b9afac95cfa29 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 29 Jan 2024 09:31:22 -0600 Subject: [PATCH] testing go Signed-off-by: Jeff Carr --- deps.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ draw.go | 19 ++++++++++++----- gitConfig.go | 4 ++-- go.mod | 16 --------------- go.sum | 14 ------------- structs.go | 6 +++--- 6 files changed, 77 insertions(+), 40 deletions(-) create mode 100644 deps.go delete mode 100644 go.mod delete mode 100644 go.sum diff --git a/deps.go b/deps.go new file mode 100644 index 0000000..68153fc --- /dev/null +++ b/deps.go @@ -0,0 +1,58 @@ +package repostatus + +import ( + "bufio" + "os" + "path/filepath" + "strings" + + "go.wit.com/log" +) + +func (rs *RepoStatus) GetGoDeps() GoConfig { + tmp := filepath.Join(rs.realPath.String(), "go.sum") + gosum, err := os.Open(tmp) + if err != nil { + log.Log(WARN, "\tmissing go.sum", rs.realPath.String()) + return nil + } + defer gosum.Close() + + var deps GoConfig + deps = make(GoConfig) + + scanner := bufio.NewScanner(gosum) + log.Info("\tgosum:", tmp) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + + parts := strings.Split(line, " ") + if len(parts) == 3 { + godep := strings.TrimSpace(parts[0]) + version := strings.TrimSpace(parts[1]) + if strings.HasSuffix(version, "/go.mod") { + version = strings.TrimSuffix(version, "/go.mod") + } + currentversion, ok := deps[godep] + if ok { + if currentversion != version { + log.Info("\tREPO:", rs.String(), rs.realPath.String()) + log.Info("\t version mismatch:", godep, version, currentversion) + return nil + } + } else { + deps[godep] = version + log.Info("\t", godep, "=", version) + } + } else { + log.Info("\t INVALID:", parts) + return nil + } + } + + if err := scanner.Err(); err != nil { + return nil + } + + return deps +} diff --git a/draw.go b/draw.go index c41e2e0..134eec0 100644 --- a/draw.go +++ b/draw.go @@ -181,7 +181,7 @@ func (rs *RepoStatus) runReleaseVersionB() bool { } func (rs *RepoStatus) runFullAutomation() bool { - if ! rs.runDevelMergeB() { + if !rs.runDevelMergeB() { log.Warn("THINGS FAILED returned false") return false } @@ -190,7 +190,7 @@ func (rs *RepoStatus) runFullAutomation() bool { label := "merge devel into " + rs.GetMasterBranchName() if label == rs.develMerge.String() { log.Warn("LABELS MATCH", label, rs.develMerge.String()) - if ! rs.runDevelMergeB() { + if !rs.runDevelMergeB() { log.Warn("THINGS FAILED returned false") return false } @@ -273,6 +273,7 @@ func (rs *RepoStatus) drawGitCommands() { } var releaseRevision string = "" + // over ride the computation of this if a release is being created func (rs *RepoStatus) setRevision(c string) { if releaseRevision == "" { @@ -354,9 +355,17 @@ func (rs *RepoStatus) setTag() bool { func (rs *RepoStatus) incrementVersion() { lasttag := rs.lasttag.String() var major, minor, revision string - major, minor, revision = splitVersion(lasttag) - log.Warn("Should release version here", lasttag) - log.Log(INFO, "Should release a,b,c", major, minor, revision) + if rs.targetReleaseVersion.String() == "" { + major, minor, revision = splitVersion(lasttag) + log.Warn("Should release version here", lasttag) + log.Log(INFO, "Should release a,b,c", major, minor, revision) + } else { + // this means there is a specific release version trying to be done + // use the target release version instead + major, minor, revision = splitVersion(rs.targetReleaseVersion.String()) + log.Warn("Should release version here", lasttag) + log.Log(INFO, "Should release a,b,c", major, minor, revision) + } a, _ := strconv.Atoi(major) b, _ := strconv.Atoi(minor) diff --git a/gitConfig.go b/gitConfig.go index 99e83c5..b10ed81 100644 --- a/gitConfig.go +++ b/gitConfig.go @@ -350,7 +350,7 @@ func (rs *RepoStatus) CheckSafeGoSumRemake() (bool, []string) { log.Log(WARN, " USER VERSIONS MATCH", version, userversion) if deprs.goSumStatus.String() == "BAD" { log.Log(WARN, " USER VERSION IS BAD!! return false") - clean = append(clean, deprs.String()) + clean = append(clean, deprs.String()) } } else { switch goSumS { @@ -369,7 +369,7 @@ func (rs *RepoStatus) CheckSafeGoSumRemake() (bool, []string) { log.Log(WARN, " go get", depname, err, output) default: log.Log(WARN, " USER VERSIONS MISMATCH", version, userversion) - clean = append(clean, deprs.String()) + clean = append(clean, deprs.String()) } } } diff --git a/go.mod b/go.mod deleted file mode 100644 index d1503b6..0000000 --- a/go.mod +++ /dev/null @@ -1,16 +0,0 @@ -module go.wit.com/lib/gui/repostatus - -go 1.21.4 - -require ( - go.wit.com/gui v0.13.18 - go.wit.com/lib/gadgets v0.13.18 - go.wit.com/log v0.13.18 - go.wit.com/widget v1.1.9 -) - -require ( - go.wit.com/dev/alexflint/arg v1.4.5 // indirect - go.wit.com/dev/alexflint/scalar v1.2.1 // indirect - go.wit.com/dev/davecgh/spew v1.1.4 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 273e29b..0000000 --- a/go.sum +++ /dev/null @@ -1,14 +0,0 @@ -go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY= -go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0= -go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs= -go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs= -go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek= -go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA= -go.wit.com/gui v0.13.18 h1:r4z1FNg6AxGWfq13+na4Xu/uA8PTTtDGka0ajo29omk= -go.wit.com/gui v0.13.18/go.mod h1:SRcfZKSbBWUxyyDiqlISWEYySoeATnijVxhzRIF0xiE= -go.wit.com/lib/gadgets v0.13.18 h1:Z35WCI6BtRamRkLTWaUP5/9+BnOGGbRdnD95SnnM6Tw= -go.wit.com/lib/gadgets v0.13.18/go.mod h1:hU0cXWfyvBrxmKD37MLyjOfJRK4+cU1aJ6lLx1CM0Qo= -go.wit.com/log v0.13.18 h1:XJNaQWX+8m12p3mH+kYih3zNjb0kScZDFpJa4c2TvKE= -go.wit.com/log v0.13.18/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= -go.wit.com/widget v1.1.9 h1:iltjAL8UZu0YPfia8/qyfDx04BDxhj8rURcx0OHVBEc= -go.wit.com/widget v1.1.9/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= diff --git a/structs.go b/structs.go index 0c2f2fd..fe16b56 100644 --- a/structs.go +++ b/structs.go @@ -46,9 +46,9 @@ type RepoStatus struct { major *gadgets.BasicCombobox revision *gadgets.BasicCombobox - versionMessage *gadgets.BasicEntry - versionCmds [][]string - versionCmdOutput *gadgets.OneLiner + versionMessage *gadgets.BasicEntry + versionCmds [][]string + versionCmdOutput *gadgets.OneLiner targetReleaseVersion *gadgets.OneLiner newversion *gui.Node