more branch debugging
This commit is contained in:
parent
a04e1784d1
commit
824c54d205
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
|||
|
||||
info: install
|
||||
# forge dirty
|
||||
forge examine
|
||||
forge examine fix
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
|
|
97
doExamine.go
97
doExamine.go
|
@ -92,6 +92,30 @@ func examineBranch(repo *gitpb.Repo) error {
|
|||
return requiresGitPush(repo, "jcarr")
|
||||
}
|
||||
|
||||
if len(dcount) == 0 {
|
||||
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())
|
||||
if argv.Examine.Fix == nil {
|
||||
log.Info(repo.GetGoPath(), cmd)
|
||||
} else {
|
||||
if _, err := repo.RunVerbose(cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
cmd = repo.ConstructGitDiffLog(repo.GetMasterBranchName(), repo.CurrentTag.Refname)
|
||||
if argv.Examine.Fix == nil {
|
||||
log.Info(repo.GetGoPath(), cmd)
|
||||
} else {
|
||||
if _, err := repo.RunVerbose(cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
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")
|
||||
return err
|
||||
}
|
||||
err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount))
|
||||
log.Info(err)
|
||||
return nil
|
||||
|
@ -124,27 +148,23 @@ func showNotDevel(repo *gitpb.Repo) ([]string, error) {
|
|||
cmd = append(cmd, repo.CurrentTag.Hash)
|
||||
cmd = append(cmd, "--not")
|
||||
cmd = append(cmd, "devel")
|
||||
r, err := repo.RunStrictNew(cmd)
|
||||
if err != nil {
|
||||
log.Info("Error", cmd, err)
|
||||
r, err := repo.RunVerboseOnError(cmd)
|
||||
return r.Stdout, err
|
||||
}
|
||||
if r == nil {
|
||||
log.Info("Error r == nil", cmd, err)
|
||||
return nil, fmt.Errorf("r == nil")
|
||||
}
|
||||
/*
|
||||
if len(r.Stdout) != 0 {
|
||||
for i, line := range r.Stdout {
|
||||
log.Info(i, line)
|
||||
}
|
||||
}
|
||||
*/
|
||||
return r.Stdout, nil
|
||||
}
|
||||
|
||||
// count all objects only in branch1
|
||||
func countDiffObjects(repo *gitpb.Repo, 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 constructGitDiffLog(repo *gitpb.Repo, branch1, branch2 string) []string {
|
||||
var cmd []string
|
||||
cmd = append(cmd, "git")
|
||||
cmd = append(cmd, "log")
|
||||
|
@ -152,47 +172,23 @@ func countDiffObjects(repo *gitpb.Repo, branch1, branch2 string) int {
|
|||
cmd = append(cmd, branch1)
|
||||
cmd = append(cmd, "--not")
|
||||
cmd = append(cmd, branch2)
|
||||
r, err := repo.RunStrictNew(cmd)
|
||||
if err != nil {
|
||||
log.Info("Error", cmd, err)
|
||||
return -1
|
||||
}
|
||||
if r == nil {
|
||||
log.Info("Error r == nil", cmd, err)
|
||||
return -1
|
||||
}
|
||||
/*
|
||||
if len(r.Stdout) != 0 {
|
||||
for i, line := range r.Stdout {
|
||||
log.Info(i, line)
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
*/
|
||||
log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " "))
|
||||
return len(r.Stdout)
|
||||
}
|
||||
|
||||
// count all objects only in branch1
|
||||
func gitPushStrict(repo *gitpb.Repo, branchName string) error {
|
||||
var cmd []string
|
||||
cmd = append(cmd, "git")
|
||||
cmd = append(cmd, "push")
|
||||
err := gitRun(repo, cmd)
|
||||
_, err := repo.RunVerbose(cmd)
|
||||
if err != nil {
|
||||
cmd = []string{"git", "whatchanged", repo.CurrentTag.Hash, "-1"}
|
||||
gitRun(repo, cmd)
|
||||
repo.RunVerbose(cmd)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func gitPushStrictExit(repo *gitpb.Repo, branchName string) {
|
||||
err := gitPushStrict(repo, branchName)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
badExit(err)
|
||||
}
|
||||
|
||||
func requiresGitPush(repo *gitpb.Repo, branchName string) error {
|
||||
b1 := countDiffObjects(repo, branchName, "origin/"+branchName)
|
||||
b2 := countDiffObjects(repo, "origin/"+branchName, branchName)
|
||||
|
@ -210,18 +206,3 @@ func requiresGitPush(repo *gitpb.Repo, branchName string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func gitRun(repo *gitpb.Repo, cmd []string) error {
|
||||
log.Info("Run:", repo.GetGoPath(), cmd)
|
||||
r, err := repo.RunStrictNew(cmd)
|
||||
if err != nil {
|
||||
log.Info("Error", cmd, err)
|
||||
}
|
||||
for _, line := range r.Stdout {
|
||||
log.Info(line)
|
||||
}
|
||||
for _, line := range r.Stderr {
|
||||
log.Info(line)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue