stop git branch delete if no local branch
This commit is contained in:
parent
cad5321516
commit
3b44a76cc4
50
doClean.go
50
doClean.go
|
@ -76,19 +76,11 @@ func doCleanDevel() error {
|
|||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
total += 1
|
||||
// devel := repo.GetDevelBranchName()
|
||||
if repo.GetDevelVersion() == "derr" {
|
||||
// already deleted
|
||||
return nil
|
||||
if !repo.IsLocalBranch(repo.GetDevelBranchName()) {
|
||||
// there is no local branch named 'devel'
|
||||
continue
|
||||
}
|
||||
/*
|
||||
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
|
||||
|
@ -107,26 +99,6 @@ func doCleanDevel() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
func checkhashes(repo *gitpb.Repo, hashes []string, refpath string) ([]string, error) {
|
||||
if !repo.Exists(refpath) {
|
||||
return hashes, nil
|
||||
}
|
||||
r, err := repo.RunStrict([]string{"cat", refpath})
|
||||
if err != nil {
|
||||
return hashes, err
|
||||
}
|
||||
newhash := r.Stdout[0]
|
||||
for _, hash := range hashes {
|
||||
if newhash != hash {
|
||||
return hashes, fmt.Errorf("%s hash broke %s %s", repo.GetGoPath(), newhash, hash)
|
||||
}
|
||||
}
|
||||
hashes = append(hashes, newhash)
|
||||
return hashes, nil
|
||||
}
|
||||
*/
|
||||
|
||||
// removes all local branches
|
||||
func doCleanUserRepo(repo *gitpb.Repo) error {
|
||||
if repo.IsDirty() {
|
||||
|
@ -136,17 +108,18 @@ func doCleanUserRepo(repo *gitpb.Repo) error {
|
|||
bruser := repo.GetUserBranchName()
|
||||
brdevel := repo.GetDevelBranchName()
|
||||
|
||||
if repo.GetUserVersion() == "uerr" {
|
||||
// already deleted
|
||||
return nil
|
||||
}
|
||||
log.Info("trying", bruser, repo.GetUserVersion())
|
||||
|
||||
if repo.IsBranchRemote(bruser) {
|
||||
log.Info("forge is designed to always have local only user branches", bruser)
|
||||
return fmt.Errorf("forge is designed to always have local only user branches")
|
||||
}
|
||||
|
||||
if !repo.IsLocalBranch(bruser) {
|
||||
// there is no local user branch
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Info("trying to delete", bruser, repo.GetUserVersion())
|
||||
|
||||
b1 := repo.CountDiffObjects(bruser, brdevel) // should be zero
|
||||
if b1 == 0 {
|
||||
cmd := []string{"git", "branch", "-D", bruser}
|
||||
|
@ -158,6 +131,7 @@ func doCleanUserRepo(repo *gitpb.Repo) error {
|
|||
return fmt.Errorf("%s branch has things not in %s count=%d", bruser, brdevel, b1)
|
||||
}
|
||||
|
||||
// hack to cleanup release versioning info
|
||||
func doCleanPub() error {
|
||||
total := 0
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
|
|
Loading…
Reference in New Issue