This commit is contained in:
Jeff Carr 2025-09-25 22:09:53 -05:00
parent 44bc7f6508
commit fc9b0a69a8
1 changed files with 26 additions and 65 deletions

View File

@ -14,68 +14,11 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
func checkRemoteBranches(repo *gitpb.Repo) error {
if err := repo.ReloadCheck(); err != nil {
log.Info("need to reload", repo.FullPath)
}
if repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) {
} else {
return log.Errorf("remote devel is out of sync with local: todo: git pull or git fetch")
}
if repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) {
} else {
return log.Errorf("remote master is out of sync with local: todo: git pull or git fetch")
}
return nil
}
/*
if repo.DevelSubsetOfUser() {
repo.DeleteDevel()
}
if repo.UserSubsetOfDevel() {
repo.DeleteUser()
}
if repo.MasterSubsetOfDevel() {
}
if "user".IsSubset("devel") {
if repo("user") >= repo("devel") {
if repo.FirstIsIncludedInSecond("devel", "user") {
if repo.IsSubset("user", "devel") {
// delete user
} else {
// figure out what to do
}
*/
// reverts all repos back to the original master branches // reverts all repos back to the original master branches
// automatically deletes local devel and user branches // automatically deletes local devel and user branches
func doClean() error { func doClean() error {
setForgeMode(forgepb.ForgeMode_CLEAN) setForgeMode(forgepb.ForgeMode_CLEAN)
/*
if argv.Clean.Verify != nil {
stats := me.forge.RillRepos(checkRemoteBranches)
for path, stat := range stats {
if stat.Err == nil {
continue
}
dur := stat.End.Sub(stat.Start)
if dur > time.Second {
log.Infof("%s checkRemoteBranches() took a long time (%s) (err=%v)\n", path, shell.FormatDuration(dur), stat.Err)
}
}
// log.Infof("%-60s, %-60s %v %s\n", stat.Start, stat.End.String(), dur, path)
// log.Infof("%-30v %s %v\n", dur, path, stat.Err)
return nil
}
*/
// fix this to work, then delete all the other options for "forge clean' // fix this to work, then delete all the other options for "forge clean'
if err := me.forge.DoAllCheckoutMaster(); err != nil { if err := me.forge.DoAllCheckoutMaster(); err != nil {
// badExit(err) // badExit(err)
@ -101,6 +44,7 @@ func doClean() error {
if err == ErrorBranchUnique { if err == ErrorBranchUnique {
if argv.Clean.Fix != nil { if argv.Clean.Fix != nil {
bname := repo.GetUserBranchName() bname := repo.GetUserBranchName()
checkPatchIds(repo, repo.GetUserBranchName(), repo.GetMasterBranchName())
s := fmt.Sprintf("delete this odd user (%s) branch %s?", bname, repo.FullPath) s := fmt.Sprintf("delete this odd user (%s) branch %s?", bname, repo.FullPath)
if fhelp.QuestionUser(s) { if fhelp.QuestionUser(s) {
repo.RunVerbose([]string{"git", "branch", "-D", bname}) repo.RunVerbose([]string{"git", "branch", "-D", bname})
@ -169,11 +113,6 @@ func doClean() error {
return nil return nil
} }
/*
func doesLocalBranchExist(repo *gitpb.Repo, branch string) bool {
return repo.Exists(filepath.Join(".git/refs/heads", branch))
}
*/
func doRepoCleanDevel(repo *gitpb.Repo) error { func doRepoCleanDevel(repo *gitpb.Repo) error {
if !repo.IsLocalBranch(repo.GetDevelBranchName()) { if !repo.IsLocalBranch(repo.GetDevelBranchName()) {
// there is no local branch named 'devel' // there is no local branch named 'devel'
@ -190,6 +129,7 @@ func doRepoCleanDevel(repo *gitpb.Repo) error {
log.Info("justDeleteTheDevel() err", repo.GetGoPath(), err) log.Info("justDeleteTheDevel() err", repo.GetGoPath(), err)
if argv.Clean.Fix != nil { if argv.Clean.Fix != nil {
bname := repo.GetDevelBranchName() bname := repo.GetDevelBranchName()
checkPatchIds(repo, repo.GetDevelBranchName(), repo.GetMasterBranchName())
s := fmt.Sprintf("delete this odd devel (%s) branch %s?", bname, repo.FullPath) s := fmt.Sprintf("delete this odd devel (%s) branch %s?", bname, repo.FullPath)
if fhelp.QuestionUser(s) { if fhelp.QuestionUser(s) {
repo.RunVerbose([]string{"git", "branch", "-D", bname}) repo.RunVerbose([]string{"git", "branch", "-D", bname})
@ -251,9 +191,6 @@ func doRepoCleanUser(repo *gitpb.Repo) error {
} }
} }
if argv.Clean.Fix != nil {
}
return ErrorBranchUnique return ErrorBranchUnique
} }
@ -318,3 +255,27 @@ func doGitReset() {
} }
} }
} }
func checkRemoteBranches(repo *gitpb.Repo) error {
if err := repo.ReloadCheck(); err != nil {
log.Info("need to reload", repo.FullPath)
}
if repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) {
} else {
return log.Errorf("remote devel is out of sync with local: todo: git pull or git fetch")
}
if repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) {
} else {
return log.Errorf("remote master is out of sync with local: todo: git pull or git fetch")
}
return nil
}
func checkPatchIds(repo *gitpb.Repo, b1 string, b2 string) error {
s1 := fmt.Sprintf("%s..%s", b1, b2)
s2 := fmt.Sprintf("%s..%s", b2, b1)
repo.RunVerbose([]string{"git", "rev-list", s1})
repo.RunVerbose([]string{"git", "rev-list", s2})
return nil
}