diff --git a/draw.go b/draw.go index c6f2c17..9047808 100644 --- a/draw.go +++ b/draw.go @@ -6,6 +6,7 @@ import ( "go.wit.com/log" "go.wit.com/gui/gui" + "go.wit.com/gui/widget" "go.wit.com/gui/gadgets" ) @@ -38,9 +39,9 @@ func (rs *RepoStatus) drawGitBranches() { all := rs.getBranches() for _, branch := range all { log.Warn("getBranches()", branch) - rs.masterDrop.Add(branch) - rs.develDrop.Add(branch) - rs.userDrop.Add(branch) + rs.masterDrop.AddText(branch) + rs.develDrop.AddText(branch) + rs.userDrop.AddText(branch) if branch == "master" { master = "master" } @@ -99,10 +100,10 @@ func (rs *RepoStatus) drawGitCommands() { rs.Update() }) - label := "merge devel to " + rs.masterDrop.Get() + label := "merge devel to " + rs.masterDrop.String() rs.develMerge = newgrid.NewButton(label, func() { rs.develMerge.Disable() - master := rs.masterDrop.Get() + master := rs.masterDrop.String() rs.checkoutBranch("master", master) if rs.getCurrentBranchName() != master { log.Warn("something went wrong switching to the master branch. full stop!") @@ -159,7 +160,7 @@ func (rs *RepoStatus) drawGitCommands() { } func (rs *RepoStatus) setTag() bool { - lasttag := rs.lasttag.Get() + lasttag := rs.lasttag.String() var major, minor, revision string major, minor, revision = splitVersion(lasttag) @@ -170,7 +171,7 @@ func (rs *RepoStatus) setTag() bool { log.Warn("current version here", lasttag) log.Warn("current release a,b,c =", major, minor, revision) - newa, _ := strconv.Atoi(rs.major.Get()) + newa, _ := strconv.Atoi(rs.major.String()) newver := strconv.Itoa(newa) if newa < olda { @@ -181,12 +182,12 @@ func (rs *RepoStatus) setTag() bool { if newa > olda { log.Warn("new version ok", newver, "vs old version", lasttag) rs.newversion.Set(newver) - rs.minor.Set("") - rs.revision.Set("") + rs.minor.SetText("") + rs.revision.SetText("") return true } - newb, _ := strconv.Atoi(rs.minor.Get()) + newb, _ := strconv.Atoi(rs.minor.String()) newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) if newb < oldb { log.Warn("new version bad", newver, "vs old version", lasttag, "newb =", newb, "oldb =", oldb) @@ -197,11 +198,11 @@ func (rs *RepoStatus) setTag() bool { if newb > oldb { log.Warn("new version ok", newver, "vs old version", lasttag) rs.newversion.Set(newver) - rs.revision.Set("") + rs.revision.SetText("") return true } - newc, _ := strconv.Atoi(rs.revision.Get()) + newc, _ := strconv.Atoi(rs.revision.String()) newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + "." + strconv.Itoa(newc) if newc <= oldc { log.Warn("new version bad", newver, "vs old version", lasttag) @@ -214,7 +215,7 @@ func (rs *RepoStatus) setTag() bool { } func (rs *RepoStatus) incrementVersion() { - lasttag := rs.lasttag.Get() + lasttag := rs.lasttag.String() var major, minor, revision string major, minor, revision = splitVersion(lasttag) log.Warn("Should release version here", lasttag) @@ -224,27 +225,27 @@ func (rs *RepoStatus) incrementVersion() { b, _ := strconv.Atoi(minor) c, _ := strconv.Atoi(revision) - rs.major.Add(a) - rs.major.Add(a + 1) - rs.major.Set(a) + rs.major.AddText(widget.GetString(a)) + rs.major.AddText(widget.GetString(a + 1)) + rs.major.SetText(widget.GetString(a)) - rs.minor.Add(b) - rs.minor.Add(b + 1) - rs.minor.Set(b) + rs.minor.AddText(widget.GetString(b)) + rs.minor.AddText(widget.GetString(b + 1)) + rs.minor.SetText(widget.GetString(b)) // rs.c := strconv.Atoi(revision) - rs.revision.Add(c + 1) - rs.revision.Add(c + 2) - rs.revision.Set(c + 1) + rs.revision.AddText(widget.GetString(c + 1)) + rs.revision.AddText(widget.GetString(c + 2)) + rs.revision.SetText(widget.GetString(c + 1)) } func (rs *RepoStatus) recommend() { - log.Warn("Is repo dirty?", rs.dirtyLabel.Get()) + log.Warn("Is repo dirty?", rs.dirtyLabel.String()) log.Warn("list the known tags") rs.DisableEverything() rs.populateTags() - log.Warn("Does devel == user?", rs.develBranchVersion.Get(), rs.userBranchVersion.Get()) - if rs.develBranchVersion.Get() != rs.userBranchVersion.Get() { + log.Warn("Does devel == user?", rs.develBranchVersion.String(), rs.userBranchVersion.String()) + if rs.develBranchVersion.String() != rs.userBranchVersion.String() { log.Warn("devel does not equal user") log.Warn("merge or squash?") rs.EnableMergeDevel() @@ -253,8 +254,8 @@ func (rs *RepoStatus) recommend() { rs.develMerge.SetText(label) return } - log.Warn("Does master == devel? ", rs.masterBranchVersion.Get(), rs.develBranchVersion.Get()) - if rs.masterBranchVersion.Get() != rs.develBranchVersion.Get() { + log.Warn("Does master == devel? ", rs.masterBranchVersion.String(), rs.develBranchVersion.String()) + if rs.masterBranchVersion.String() != rs.develBranchVersion.String() { log.Warn("master does not equal devel. merge devel into master") rs.EnableMergeDevel() rs.setMergeDevelCommands() @@ -263,7 +264,7 @@ func (rs *RepoStatus) recommend() { return } rs.getLastTagVersion() - if rs.lasttag.Get() != rs.masterBranchVersion.Get() { + if rs.lasttag.String() != rs.masterBranchVersion.String() { log.Warn("master does not equal last tag") rs.incrementVersion() rs.EnableSelectTag() @@ -289,12 +290,12 @@ func (rs *RepoStatus) generateCmd() bool { log.Warn("tag is valid!!!!") rs.setGitCommands() - if rs.versionMessage.Get() == "" { + if rs.versionMessage.String() == "" { log.Warn("tag message is empty!!!!") rs.releaseVersion.Disable() return false } - if len(rs.versionMessage.Get()) > 24 { + if len(rs.versionMessage.String()) > 24 { rs.versionMessage.SetLabel("tag message (too long)") } else { rs.versionMessage.SetLabel("tag message") @@ -326,8 +327,8 @@ func (rs *RepoStatus) setGitCommands() { var line1, line2, line3 []string var all [][]string - newTag := rs.newversion.GetText() - line1 = append(line1, "git", "tag", "v" + newTag, "-m", rs.versionMessage.Get()) + newTag := rs.newversion.String() + line1 = append(line1, "git", "tag", "v" + newTag, "-m", rs.versionMessage.String()) all = append(all, line1) line2 = append(line2, "git", "push", "--tags") all = append(all, line2) @@ -344,7 +345,7 @@ func (rs *RepoStatus) setGitCommands() { tmp = append(tmp, s) } - rs.versionCmdOutput.Set(strings.Join(tmp, "\n")) + rs.versionCmdOutput.SetText(strings.Join(tmp, "\n")) } func (rs *RepoStatus) setMergeDevelCommands() { @@ -371,7 +372,7 @@ func (rs *RepoStatus) setMergeDevelCommands() { tmp = append(tmp, s) } - rs.versionCmdOutput.Set(strings.Join(tmp, "\n")) + rs.versionCmdOutput.SetText(strings.Join(tmp, "\n")) } func (rs *RepoStatus) setMergeUserCommands() { @@ -398,5 +399,5 @@ func (rs *RepoStatus) setMergeUserCommands() { tmp = append(tmp, s) } - rs.versionCmdOutput.Set(strings.Join(tmp, "\n")) + rs.versionCmdOutput.SetText(strings.Join(tmp, "\n")) } diff --git a/git.go b/git.go index 46c3237..7fa6b98 100644 --- a/git.go +++ b/git.go @@ -13,28 +13,28 @@ func (rs *RepoStatus) GetPath() string { } func (rs *RepoStatus) GetCurrentBranchName() string { - return rs.currentBranch.Get() + return rs.currentBranch.String() } func (rs *RepoStatus) GetCurrentBranchVersion() string { - return rs.currentVersion.Get() + return rs.currentVersion.String() } func (rs *RepoStatus) GetLastTagVersion() string { - return rs.lasttag.Get() + return rs.lasttag.String() } func (rs *RepoStatus) getCurrentBranchName() string { out := run(rs.repopath, "git", "branch --show-current") log.Warn("getCurrentBranchName() =", out) - rs.currentBranch.Set(out) + rs.currentBranch.SetText(out) return out } func (rs *RepoStatus) getCurrentBranchVersion() string { out := run(rs.repopath, "git", "describe --tags") log.Warn("getCurrentBranchVersion()", out) - rs.currentVersion.Set(out) + rs.currentVersion.SetText(out) return out } @@ -46,9 +46,9 @@ func (rs *RepoStatus) getLastTagVersion() string { lastreal := "describe --tags " + out // out = run(r.path, "git", "describe --tags c871d5ecf051a7dc4e3a77157cdbc0a457eb9ae1") out = run(rs.repopath, "git", lastreal) - rs.lasttag.Set(out) - rs.tagsDrop.Set(out) - // rs.lastLabel.Set(out) + rs.lasttag.SetText(out) + rs.tagsDrop.SetText(out) + // rs.lastLabel.SetText(out) return out } @@ -58,11 +58,11 @@ func (rs *RepoStatus) populateTags() { for _, tag := range listFiles(tmp) { if rs.tags[tag] == "" { log.Warn("populateTags() Adding new tag", tag) - rs.tagsDrop.Add(tag) + rs.tagsDrop.AddText(tag) rs.tags[tag] = "origin" } } - // rs.tagsDrop.Set(rs.lasttagrev) + // rs.tagsDrop.SetText(rs.lasttagrev) } /* @@ -104,17 +104,17 @@ func (rs *RepoStatus) CheckDirty() bool { log.Warn("CheckDirty() out =", out) log.Warn("CheckDirty() err =", err) log.Error(err, "CheckDirty() error") - rs.dirtyLabel.Set("error") + rs.dirtyLabel.SetText("error") return true } if b { log.Warn("CheckDirty() b =", b, "path =", path, "out =", out) log.Warn("CheckDirty() no", rs.repopath) - rs.dirtyLabel.Set("no") + rs.dirtyLabel.SetText("no") return false } log.Warn("CheckDirty() true", rs.repopath) - rs.dirtyLabel.Set("dirty") + rs.dirtyLabel.SetText("dirty") return true } @@ -142,61 +142,61 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) { switch level { case "master": - rs.masterBranchVersion.Set(realversion) + rs.masterBranchVersion.SetText(realversion) case "devel": - rs.develBranchVersion.Set(realversion) + rs.develBranchVersion.SetText(realversion) case "user": - rs.userBranchVersion.Set(realversion) + rs.userBranchVersion.SetText(realversion) default: } } func (rs *RepoStatus) SetMasterName(s string) { - rs.masterDrop.Set(s) + rs.masterDrop.SetText(s) rs.masterBranchVersion.SetLabel(s) // rs.major.SetTitle(s) } func (rs *RepoStatus) SetDevelName(s string) { - rs.develDrop.Set(s) + rs.develDrop.SetText(s) rs.develBranchVersion.SetLabel(s) } func (rs *RepoStatus) SetUserName(s string) { - rs.userDrop.Set(s) + rs.userDrop.SetText(s) rs.userBranchVersion.SetLabel(s) } // returns "master", "devel", os.Username, etc func (rs *RepoStatus) GetMasterName() string { - name := rs.masterDrop.Get() + name := rs.masterDrop.String() log.Warn("GetMasterName() =", name) return name } func (rs *RepoStatus) GetDevelName() string { - name := rs.develDrop.Get() + name := rs.develDrop.String() log.Warn("GetDevelName() =", name) return name } func (rs *RepoStatus) GetUserName() string { - name := rs.userDrop.Get() + name := rs.userDrop.String() log.Warn("GetUserName() =", name) return name } // returns the git versions like "1.3-2-laksdjf" or whatever func (rs *RepoStatus) GetMasterVersion() string { - name := rs.masterBranchVersion.Get() + name := rs.masterBranchVersion.String() log.Warn("GetMasterVersion() =", name) return name } func (rs *RepoStatus) GetDevelVersion() string { - name := rs.develBranchVersion.Get() + name := rs.develBranchVersion.String() log.Warn("GetBranchVersion() =", name) return name } func (rs *RepoStatus) GetUserVersion() string { - name := rs.userBranchVersion.Get() + name := rs.userBranchVersion.String() log.Warn("GetUserVersion() =", name) return name } diff --git a/timer.go b/timer.go index 9e9e589..0ba5faf 100644 --- a/timer.go +++ b/timer.go @@ -13,5 +13,5 @@ func timeFunction(f func()) time.Duration { func (ls *RepoStatus) SetSpeedActual(s string) { if ! ls.Ready() {return} - ls.speedActual.Set(s) + ls.speedActual.SetText(s) } diff --git a/update.go b/update.go index 429920c..892ebfb 100644 --- a/update.go +++ b/update.go @@ -17,8 +17,8 @@ func (rs *RepoStatus) Update() { log.Log(WARN, "Update() START") duration := timeFunction(func () { // do things that are safe even if the git tree is dirty - log.Warn("path.Set()") - rs.path.Set(rs.repopath) + log.Warn("path.SetText()") + rs.path.SetText(rs.repopath) log.Warn("getCurrentBranchName()") rs.getCurrentBranchName() log.Warn("set window Title()") @@ -32,15 +32,15 @@ func (rs *RepoStatus) Update() { log.Warn("CheckDirty()") rs.CheckDirty() - if rs.dirtyLabel.Get() != "no" { - log.Warn("dirty label != no. actual value:", rs.dirtyLabel.Get()) + if rs.dirtyLabel.String() != "no" { + log.Warn("dirty label != no. actual value:", rs.dirtyLabel.String()) rs.DisableEverything() return } - master := rs.masterDrop.Get() - devel := rs.develDrop.Get() - user := rs.userDrop.Get() + master := rs.masterDrop.String() + devel := rs.develDrop.String() + user := rs.userDrop.String() // rs.CheckDirty() this runs log.Log(WARN, "") @@ -65,14 +65,14 @@ func (rs *RepoStatus) setSpeed(duration time.Duration) { log.Log(WARN, "can't actually warn") return } - rs.speedActual.Set(s) + rs.speedActual.SetText(s) if (duration > 500 * time.Millisecond ) { - rs.speed.Set("SLOW") + rs.speed.SetText("SLOW") } else if (duration > 100 * time.Millisecond ) { - rs.speed.Set("OK") + rs.speed.SetText("OK") } else { - rs.speed.Set("FAST") + rs.speed.SetText("FAST") } }