summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-18 05:48:21 -0600
committerJeff Carr <[email protected]>2025-01-18 05:48:21 -0600
commitdcc51eb7768f0986a0fab7b90e5f3db5373b870e (patch)
treebf3a40498992481935268f05cb993d2031afdd62
parent824c54d205be24ca1324963f71927afd7573b72e (diff)
more tracking down of the master branch namev0.22.45
-rw-r--r--Makefile2
-rw-r--r--doExamine.go48
2 files changed, 47 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index e4af688..3534d50 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
info: install
# forge dirty
- forge examine fix
+ forge examine
vet:
@GO111MODULE=off go vet
diff --git a/doExamine.go b/doExamine.go
index c1d3d54..4609c68 100644
--- a/doExamine.go
+++ b/doExamine.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "path/filepath"
"slices"
"strings"
"time"
@@ -76,7 +77,11 @@ func isNormal(repo *gitpb.Repo) bool {
}
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 {
return err
}
@@ -93,6 +98,12 @@ func examineBranch(repo *gitpb.Repo) error {
}
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)
log.Info(err)
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}
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
}
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
}
+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) {
var cmd []string
cmd = append(cmd, "git")