seems like it can clean the repos okay now
This commit is contained in:
parent
620569a97c
commit
23c730cd85
71
doClean.go
71
doClean.go
|
@ -50,20 +50,24 @@ func doCleanUser() error {
|
|||
// return err
|
||||
}
|
||||
|
||||
var anyerr error
|
||||
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
if err := doCleanUserRepo(repo); err != nil {
|
||||
log.Info(repo.GetGoPath(), err)
|
||||
return err
|
||||
anyerr = err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return anyerr
|
||||
}
|
||||
|
||||
/*
|
||||
func doesLocalBranchExist(repo *gitpb.Repo, branch string) bool {
|
||||
return repo.Exists(filepath.Join(".git/refs/heads", branch))
|
||||
}
|
||||
*/
|
||||
|
||||
func doCleanDevel() error {
|
||||
var total int
|
||||
|
@ -72,13 +76,19 @@ func doCleanDevel() error {
|
|||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
total += 1
|
||||
devel := repo.GetDevelBranchName()
|
||||
// devel := repo.GetDevelBranchName()
|
||||
if repo.GetDevelVersion() == "derr" {
|
||||
// already deleted
|
||||
return nil
|
||||
}
|
||||
/*
|
||||
if !doesLocalBranchExist(repo, devel) {
|
||||
if argv.Verbose {
|
||||
log.Info("local branch was already deleted:", repo.GetGoPath())
|
||||
}
|
||||
continue
|
||||
}
|
||||
*/
|
||||
if repo.GetCurrentBranchName() != repo.GetMasterBranchName() {
|
||||
log.Info("Repo not on master branch:", repo.GetGoPath())
|
||||
continue
|
||||
|
@ -98,17 +108,6 @@ func doCleanDevel() error {
|
|||
}
|
||||
|
||||
/*
|
||||
func exactDevelRepo(repo *gitpb.Repo) error {
|
||||
devel := repo.GetDevelBranchName()
|
||||
master := repo.GetMasterBranchName()
|
||||
err := isBranchSubsetOfTrunk(repo, devel, master)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
|
||||
func checkhashes(repo *gitpb.Repo, hashes []string, refpath string) ([]string, error) {
|
||||
if !repo.Exists(refpath) {
|
||||
return hashes, nil
|
||||
|
@ -126,6 +125,7 @@ func checkhashes(repo *gitpb.Repo, hashes []string, refpath string) ([]string, e
|
|||
hashes = append(hashes, newhash)
|
||||
return hashes, nil
|
||||
}
|
||||
*/
|
||||
|
||||
// removes all local branches
|
||||
func doCleanUserRepo(repo *gitpb.Repo) error {
|
||||
|
@ -158,49 +158,6 @@ func doCleanUserRepo(repo *gitpb.Repo) error {
|
|||
return fmt.Errorf("%s branch has things not in %s count=%d", bruser, brdevel, b1)
|
||||
}
|
||||
|
||||
/*
|
||||
// verifies that the branch is a pure subset of the other branch
|
||||
// sorry about the 'master' 'slave' nameing thing. I guess that isn't
|
||||
// 'cool' to use anymore. I can't think of other terms that aren't reserved words.
|
||||
func isBranchSubsetOfTrunk(repo *gitpb.Repo, branch string, trunk string) error {
|
||||
b1 := countGitDiffLog(repo, branch, trunk) // should be zero
|
||||
b2 := countGitDiffLog(repo, trunk, branch) // can be greater than 1
|
||||
// log.Info(branch, "vs", trunk, "count", b1, b2)
|
||||
if b1 == 0 && b2 == 0 {
|
||||
// log.Info("branch and trunk are identical ==", branch, b1, trunk, b2)
|
||||
return nil
|
||||
}
|
||||
if argv.Verbose {
|
||||
log.Printf("%-40s NOT EXACT %s %s (%d) (%d)\n", repo.GetGoPath(), branch, trunk, b1, b2)
|
||||
}
|
||||
if b1 == 0 {
|
||||
cmd := []string{"git", "merge", trunk}
|
||||
log.Printf("%-40s branch %s needs merge with trunk %s len(%d) %s\n", repo.GetGoPath(), branch, trunk, b2, cmd)
|
||||
return ErrorMergeBranch
|
||||
}
|
||||
if b2 == 0 {
|
||||
log.Printf("%-40s trunk %s needs merge with branch %s len(%d)\n", repo.GetGoPath(), branch, trunk, b2)
|
||||
return ErrorMergeTrunk
|
||||
}
|
||||
return fmt.Errorf("branch not clean to delete. needs merge %d %d", b1, b2)
|
||||
}
|
||||
*/
|
||||
|
||||
// count all objects only in branch1
|
||||
// if zero, that means branch1 is entirely contained in branch2 and can be safely deleted
|
||||
|
||||
/*
|
||||
func countGitDiffLog(repo *gitpb.Repo, branch1, branch2 string) int {
|
||||
cmd := repo.ConstructGitDiffLog(branch1, branch2)
|
||||
r, err := repo.RunStrict(cmd)
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
// log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " "))
|
||||
return len(r.Stdout)
|
||||
}
|
||||
*/
|
||||
|
||||
func doCleanPub() error {
|
||||
total := 0
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
|
|
Loading…
Reference in New Issue