more tracking down of the master branch name

This commit is contained in:
Jeff Carr 2025-01-18 05:48:21 -06:00
parent 824c54d205
commit dcc51eb776
2 changed files with 47 additions and 3 deletions

View File

@ -3,7 +3,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
info: install info: install
# forge dirty # forge dirty
forge examine fix forge examine
vet: vet:
@GO111MODULE=off go vet @GO111MODULE=off go vet

View File

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"path/filepath"
"slices" "slices"
"strings" "strings"
"time" "time"
@ -76,7 +77,11 @@ func isNormal(repo *gitpb.Repo) bool {
} }
func examineBranch(repo *gitpb.Repo) error { func examineBranch(repo *gitpb.Repo) error {
dcount, err := showNotDevel(repo) if !isLocal(repo) {
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
return fmt.Errorf("%s repo.CurrentTag is not local: %s. Don't proceed yet", repo.GetGoPath(), repo.CurrentTag.Refname)
}
dcount, err := showNotMaster(repo)
if err != nil { if err != nil {
return err return err
} }
@ -93,6 +98,12 @@ func examineBranch(repo *gitpb.Repo) error {
} }
if len(dcount) == 0 { if len(dcount) == 0 {
if repo.CurrentTag.Refname == repo.GetMasterBranchName() {
err = fmt.Errorf("examineBranch() SPECIAL CASE. %s is the master branch", repo.CurrentTag.Refname)
log.Info(err)
return err
}
err = fmt.Errorf("examineBranch() branch differs. patch diff len == 0. PROBABLY DELETE BRANCH %s", repo.CurrentTag.Refname) err = fmt.Errorf("examineBranch() branch differs. patch diff len == 0. PROBABLY DELETE BRANCH %s", repo.CurrentTag.Refname)
log.Info(err) log.Info(err)
cmd := repo.ConstructGitDiffLog(repo.CurrentTag.Refname, repo.GetMasterBranchName()) cmd := repo.ConstructGitDiffLog(repo.CurrentTag.Refname, repo.GetMasterBranchName())
@ -113,7 +124,17 @@ func examineBranch(repo *gitpb.Repo) error {
} }
cmd = []string{"git", "branch", "-D", repo.CurrentTag.Refname} cmd = []string{"git", "branch", "-D", repo.CurrentTag.Refname}
log.Info(repo.GetGoPath(), "TRY THIS:", cmd) log.Info(repo.GetGoPath(), "TRY THIS:", cmd)
log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST") if argv.Examine.Fix == nil {
log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
} else {
log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
if _, err := repo.RunVerbose(cmd); err != nil {
return err
} else {
return nil
}
}
return err return err
} }
err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount)) err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount))
@ -140,6 +161,29 @@ func checkJcarr(repo *gitpb.Repo) int {
return -1 return -1
} }
func isLocal(repo *gitpb.Repo) bool {
base, name := filepath.Split(repo.CurrentTag.Refname)
if name == "" {
return false
}
if base == "" {
return true
}
return false
}
func showNotMaster(repo *gitpb.Repo) ([]string, error) {
var cmd []string
cmd = append(cmd, "git")
cmd = append(cmd, "log")
cmd = append(cmd, "--format=\"%H\"")
cmd = append(cmd, repo.CurrentTag.Hash)
cmd = append(cmd, "--not")
cmd = append(cmd, repo.GetMasterBranchName())
r, err := repo.RunVerboseOnError(cmd)
return r.Stdout, err
}
func showNotDevel(repo *gitpb.Repo) ([]string, error) { func showNotDevel(repo *gitpb.Repo) ([]string, error) {
var cmd []string var cmd []string
cmd = append(cmd, "git") cmd = append(cmd, "git")