stuff
This commit is contained in:
parent
44bc7f6508
commit
fc9b0a69a8
91
doClean.go
91
doClean.go
|
@ -14,68 +14,11 @@ import (
|
|||
"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
|
||||
// automatically deletes local devel and user branches
|
||||
func doClean() error {
|
||||
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'
|
||||
if err := me.forge.DoAllCheckoutMaster(); err != nil {
|
||||
// badExit(err)
|
||||
|
@ -101,6 +44,7 @@ func doClean() error {
|
|||
if err == ErrorBranchUnique {
|
||||
if argv.Clean.Fix != nil {
|
||||
bname := repo.GetUserBranchName()
|
||||
checkPatchIds(repo, repo.GetUserBranchName(), repo.GetMasterBranchName())
|
||||
s := fmt.Sprintf("delete this odd user (%s) branch %s?", bname, repo.FullPath)
|
||||
if fhelp.QuestionUser(s) {
|
||||
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
||||
|
@ -169,11 +113,6 @@ func doClean() error {
|
|||
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 {
|
||||
if !repo.IsLocalBranch(repo.GetDevelBranchName()) {
|
||||
// there is no local branch named 'devel'
|
||||
|
@ -190,6 +129,7 @@ func doRepoCleanDevel(repo *gitpb.Repo) error {
|
|||
log.Info("justDeleteTheDevel() err", repo.GetGoPath(), err)
|
||||
if argv.Clean.Fix != nil {
|
||||
bname := repo.GetDevelBranchName()
|
||||
checkPatchIds(repo, repo.GetDevelBranchName(), repo.GetMasterBranchName())
|
||||
s := fmt.Sprintf("delete this odd devel (%s) branch %s?", bname, repo.FullPath)
|
||||
if fhelp.QuestionUser(s) {
|
||||
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
||||
|
@ -251,9 +191,6 @@ func doRepoCleanUser(repo *gitpb.Repo) error {
|
|||
}
|
||||
}
|
||||
|
||||
if argv.Clean.Fix != nil {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue