From bb54c065adc7734c533a54c819ada8591e9a0a9c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 9 Feb 2025 14:18:18 -0600 Subject: [PATCH] check for the terrible situation of devel < master --- reloadRepoState.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/reloadRepoState.go b/reloadRepoState.go index 9536234..b6cb20a 100644 --- a/reloadRepoState.go +++ b/reloadRepoState.go @@ -6,6 +6,17 @@ import ( "go.wit.com/log" ) +// count all objects only in branch1 +func (repo *Repo) countDiffObjects(branch1, branch2 string) int { + cmd := repo.ConstructGitDiffLog(branch1, branch2) + r, err := repo.RunVerboseOnError(cmd) + if err != nil { + return -1 + } + // log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " ")) + return len(r.Stdout) +} + func (repo *Repo) setRepoState() { if repo == nil { return @@ -23,7 +34,15 @@ func (repo *Repo) setRepoState() { } } if repo.GetDevelVersion() != repo.GetMasterVersion() { - repo.State = "merge to main" + b1 := repo.countDiffObjects(repo.GetMasterBranchName(), repo.GetDevelBranchName()) + if b1 == 0 { + repo.State = "merge to main" + // log.Info("master vs devel count is normal b1 == 0", b1) + } else { + repo.State = "DEVEL < MASTER" + // log.Info("master vs devel count b1 != 0", b1) + log.Info("SERIOUS ERROR. DEVEL BRANCH NEEDS MERGE FROM MASTER b1 ==", b1, repo.GetGoPath()) + } return } // if IsGoTagVersionGreater(oldtag string, newtag string) bool {