check for the terrible situation of devel < master

This commit is contained in:
Jeff Carr 2025-02-09 14:18:18 -06:00
parent 11d1136797
commit bb54c065ad
1 changed files with 20 additions and 1 deletions

View File

@ -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 {