diff options
Diffstat (limited to 'doVerifyDevel.go')
| -rw-r--r-- | doVerifyDevel.go | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/doVerifyDevel.go b/doVerifyDevel.go new file mode 100644 index 0000000..b8fd419 --- /dev/null +++ b/doVerifyDevel.go @@ -0,0 +1,90 @@ +package main + +import ( + "path/filepath" + + "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" +) + +func doVerifyDevel() error { + me.found = new(gitpb.Repos) + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if repo.IsDirty() { + log.Info(repo.GetGoPath(), "is dirty") + continue + } + if repo.GetDevelBranchName() == "" { + continue + } + if repo.GetMasterBranchName() != repo.GetCurrentBranchName() { + log.Info(repo.GetGoPath(), "is not on master branch") + continue + } + + // check if devel branch exists in remote repo + devel := repo.GetDevelBranchName() + if argv.Verbose { + log.Printf("Start clean devel branch: %s %s\n", repo.GetGoPath(), devel) + } + + if repo.Exists(filepath.Join(".git/refs/remotes/origin", devel)) { + // todo: actually use .git/config + if err := doCleanDevelRepo(repo); err != nil { + log.Info(repo.GetGoPath(), "verify clean failed") + } + // can not continue + continue + } + // devel branch is only local + /* + devname := repo.GetDevelBranchName() + if err := requiresGitPush(repo, devname); err != nil { + log.Info(repo.GetGoPath(), "is out of sync with upstream") + return err + } + */ + } + return nil +} + +/* + 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.Clean.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.Clean.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) + if argv.Clean.Examine.Fix == nil { + log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname) + repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"}) + } else { + log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname) + if _, err := repo.RunVerbose(cmd); err != nil { + return err + } else { + return nil + } + } + return err + } + err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount)) + log.Info(err) + return nil +*/ |
