more tracking down of the master branch name
This commit is contained in:
parent
824c54d205
commit
dcc51eb776
2
Makefile
2
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
|
||||
|
|
48
doExamine.go
48
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")
|
||||
|
|
Loading…
Reference in New Issue