diff --git a/common.go b/common.go index 0ec5cb8..f2536a1 100644 --- a/common.go +++ b/common.go @@ -11,11 +11,8 @@ func (rs *RepoStatus) Changed() bool { if !rs.Ready() { return false } - if rs.changed { - rs.changed = false - return true - } - return false + + return rs.changed } func (rs *RepoStatus) Draw() { diff --git a/draw.go b/draw.go index 22a3275..6ab130e 100644 --- a/draw.go +++ b/draw.go @@ -102,9 +102,9 @@ func (rs *RepoStatus) drawGitCommands() { rs.Update() }) - label := "merge devel to " + rs.masterDrop.String() + label := "merge " + rs.masterDrop.String() + " to devel" rs.develMerge = newgrid.NewButton(label, func() { - rs.develMerge.Disable() + rs.Disable() master := rs.masterDrop.String() rs.checkoutBranch("master", master) if rs.getCurrentBranchName() != master { @@ -116,6 +116,7 @@ func (rs *RepoStatus) drawGitCommands() { return } rs.Update() + rs.Enable() log.Warn("THINGS SEEM OK") }) @@ -252,7 +253,7 @@ func (rs *RepoStatus) recommend() { log.Warn("merge or squash?") rs.EnableMergeDevel() rs.setMergeUserCommands() - label := "merge " + rs.GetUserName() + " into " + rs.GetDevelName() + label := "merge " + rs.GetUserBranchName() + " into " + rs.GetDevelBranchName() rs.develMerge.SetText(label) return } @@ -261,7 +262,7 @@ func (rs *RepoStatus) recommend() { log.Warn("master does not equal devel. merge devel into master") rs.EnableMergeDevel() rs.setMergeDevelCommands() - label := "merge " + rs.GetDevelName() + " into " + rs.GetMasterName() + label := "merge " + rs.GetDevelBranchName() + " into " + rs.GetMasterBranchName() rs.develMerge.SetText(label) return } @@ -355,8 +356,8 @@ func (rs *RepoStatus) setMergeDevelCommands() { var line1, line2, line3 []string var all [][]string - master := rs.GetMasterName() - devel := rs.GetDevelName() + master := rs.GetMasterBranchName() + devel := rs.GetDevelBranchName() line1 = append(line1, "git", "checkout", master) all = append(all, line1) @@ -382,8 +383,8 @@ func (rs *RepoStatus) setMergeUserCommands() { var line1, line2, line3 []string var all [][]string - devel := rs.GetDevelName() - user := rs.GetUserName() + devel := rs.GetDevelBranchName() + user := rs.GetUserBranchName() line1 = append(line1, "git", "checkout", devel) all = append(all, line1) diff --git a/git.go b/git.go index a90ac57..61fc2c8 100644 --- a/git.go +++ b/git.go @@ -156,36 +156,36 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) { } } -func (rs *RepoStatus) SetMasterName(s string) { +func (rs *RepoStatus) SetMasterBranchName(s string) { rs.masterDrop.SetText(s) rs.masterBranchVersion.SetLabel(s) // rs.major.SetTitle(s) } -func (rs *RepoStatus) SetDevelName(s string) { +func (rs *RepoStatus) SetDevelBranchName(s string) { rs.develDrop.SetText(s) rs.develBranchVersion.SetLabel(s) } -func (rs *RepoStatus) SetUserName(s string) { +func (rs *RepoStatus) SetUserBranchName(s string) { rs.userDrop.SetText(s) rs.userBranchVersion.SetLabel(s) } // returns "master", "devel", os.Username, etc -func (rs *RepoStatus) GetMasterName() string { +func (rs *RepoStatus) GetMasterBranchName() string { name := rs.masterDrop.String() log.Warn("GetMasterName() =", name) return name } -func (rs *RepoStatus) GetDevelName() string { +func (rs *RepoStatus) GetDevelBranchName() string { name := rs.develDrop.String() log.Warn("GetDevelName() =", name) return name } -func (rs *RepoStatus) GetUserName() string { +func (rs *RepoStatus) GetUserBranchName() string { name := rs.userDrop.String() - log.Warn("GetUserName() =", name) + log.Warn("GetUserBranchName() =", name) return name } @@ -206,6 +206,54 @@ func (rs *RepoStatus) GetUserVersion() string { return name } +func (rs *RepoStatus) SetMasterVersion(s string) { + if rs.GetMasterVersion() == s { + return + } + rs.changed = true + log.Warn("git", rs.GetMasterBranchName(), "version now =", s) + rs.masterBranchVersion.SetValue(s) +} + +func (rs *RepoStatus) SetDevelVersion(s string) { + if rs.GetDevelVersion() == s { + return + } + rs.changed = true + log.Warn("git", rs.GetDevelBranchName(), "version now =", s) + rs.develBranchVersion.SetValue(s) +} + +func (rs *RepoStatus) SetUserVersion(s string) { + if rs.GetUserVersion() == s { + return + } + rs.changed = true + log.Warn("git", rs.GetUserBranchName(), "version now =", s) + rs.userBranchVersion.SetValue(s) +} + +func (rs *RepoStatus) GetStatus() string { + rs.changed = false + if rs.CheckDirty() { + log.Warn("CheckDirty() true") + return "dirty" + } + if rs.userBranchVersion.String() != rs.develBranchVersion.String() { + return "merge to devel" + } + if rs.userBranchVersion.String() != rs.masterBranchVersion.String() { + return "release" + } + + if rs.CheckBranches() { + log.Warn("Branches are Perfect") + return "PERFECT" + } + log.Warn("Branches are not Perfect") + return "unknown branches" +} + // TODO: make this report the error somewhere func (rs *RepoStatus) CheckBranches() bool { var hashCheck string diff --git a/update.go b/update.go index 6033fb7..0feb90a 100644 --- a/update.go +++ b/update.go @@ -97,6 +97,14 @@ func (rs *RepoStatus) EnableMergeDevel() { rs.develMerge.Enable() } +func (rs *RepoStatus) Disable() { + rs.window.Disable() +} + +func (rs *RepoStatus) Enable() { + rs.window.Enable() +} + // this means you need to release a new version of the master repository func (rs *RepoStatus) EnableSelectTag() { rs.DisableEverything()