lots of changes here and in gitpb

This commit is contained in:
Jeff Carr 2024-12-17 06:36:00 -06:00
parent ac029ee52c
commit 36073faed5
8 changed files with 80 additions and 61 deletions

View File

@ -2,7 +2,10 @@ VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
all: install
forge
@echo make private # only the private ones
@echo make mine # just show my repos
@echo make restart # remove the repos.pb file
@echo make pull # run git pull on every repo
vet:
@GO111MODULE=off go vet
@ -37,6 +40,9 @@ private: install
fix: install
forge --fix --find-all
all: install
forge --find-all
git-reset: install
forge --do-git-reset --find-all
@ -66,3 +72,8 @@ patches-localhost: install
patches-list: install
forge --list-patches --url "http://localhost:2233/"
restart:
reset
rm ~/go/src/repos.pb
make config

View File

@ -2,7 +2,6 @@ package main
import (
"fmt"
"os"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
@ -34,7 +33,7 @@ func doCobol() {
log.DaemonMode(true)
log.Info(standardStart5("gopath", "cur name", "master", "user", "repo type"))
all := me.found.SortByGoPath()
all := me.found.SortByFullPath()
for all.Scan() {
repo := all.Next()
verifyPrint(repo)
@ -78,19 +77,12 @@ func verifyPrint(repo *gitpb.Repo) {
}
s := make(map[string]string)
if !verify(repo, s) {
log.Info("going to delete", repo.GoPath)
log.Info("going to delete", repo.GetGoPath())
if argv.Fix {
me.forge.Repos.DeleteByGoPath(repo.GetGoPath())
me.forge.DeleteByGoPath(repo.GetGoPath())
me.forge.Repos.ConfigSave()
} else {
log.Info("need argv --real to delete", repo.GoPath)
os.Exit(0)
}
}
if me.forge.Config.IsReadOnly(repo.GoPath) {
if repo.ReadOnly {
} else {
log.Info("readonly flag on repo is wrong", repo.GoPath)
log.Info("need argv --fix to delete", repo.GetGoPath())
}
}
@ -101,7 +93,7 @@ func verifyPrint(repo *gitpb.Repo) {
// start := fmt.Sprintf("%-40s %-12s %-12s %-12s %-8s", s["gopath"], cname, mhort, uhort, s["rtype"])
start := standardStart5(s["gopath"], cname, mhort, uhort, s["rtype"])
if me.forge.Config.IsReadOnly(repo.GoPath) {
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
end += "(readonly) "
}
@ -110,46 +102,39 @@ func verifyPrint(repo *gitpb.Repo) {
func verify(repo *gitpb.Repo, s map[string]string) bool {
s["gopath"] = repo.GetGoPath()
s["rtype"] = repo.RepoType()
s["rtype"] = repo.GetRepoType()
s["mname"] = repo.GetMasterBranchName()
if s["mname"] == "" {
log.Info("verify() no master branch name", repo.GoPath)
log.Info("verify() no master branch name", repo.FullPath)
s["mver"] = repo.GetMasterVersion()
return false
}
// only verify the master branch name with read-only repos
if me.forge.Config.IsReadOnly(repo.GoPath) {
s["mver"] = repo.GetMasterVersion()
return true
// return false
}
s["mver"] = repo.GetMasterVersion()
s["dname"] = repo.GetDevelBranchName()
if s["dname"] == "" {
log.Info("verify() no devel branch name", repo.GoPath)
return false
log.Info("verify() no devel branch name", repo.GetGoPath())
// return false
}
s["uname"] = repo.GetUserBranchName()
if s["uname"] == "" {
log.Info("verify() no user branch name", repo.GoPath)
return false
log.Info("verify() no user branch name", repo.GetGoPath())
// return false
}
s["cname"] = repo.GetCurrentBranchName()
s["mver"] = repo.GetMasterVersion()
if s["mver"] == "" {
log.Info("verify() no master branch name", repo.GoPath, repo.GetMasterBranchName())
return false
log.Info("verify() no master branch name", repo.FullPath, repo.GetMasterBranchName())
}
s["dver"] = repo.GetDevelVersion()
if s["dver"] == "" {
log.Info("verify() no devel branch name", repo.GoPath, repo.GetDevelBranchName())
return false
log.Info("verify() no devel branch name", repo.GetGoPath(), repo.GetDevelBranchName())
}
s["uver"] = repo.GetUserVersion()
if s["uver"] == "" {
log.Info("verify() no user branch name", repo.GoPath, repo.GetUserBranchName())
return false
log.Info("verify() no user branch name", repo.GetGoPath(), repo.GetUserBranchName())
}
s["cver"] = repo.GetCurrentBranchVersion()
s["url"] = repo.URL

View File

@ -12,24 +12,24 @@ func doScan() {
func doGitPull() {
allerr := me.found.RillGitPull(40, 5)
all := me.found.SortByGoPath()
all := me.found.SortByFullPath()
for all.Scan() {
repo := all.Next()
result := allerr[repo]
if result.Error == gitpb.ErrorGitPullOnDirty {
log.Info("skip git pull. repo is dirty", repo.GoPath)
log.Info("skip git pull. repo is dirty", repo.GetGoPath())
continue
}
if result.Error == gitpb.ErrorGitPullOnLocal {
log.Info("skip git pull. local branch ", repo.GoPath)
log.Info("skip git pull. local branch ", repo.GetGoPath())
continue
}
if result.Exit == 0 {
continue
}
log.Info("git pull error:", repo.GoPath, result.Error)
log.Info("git pull error:", repo.GoPath, result.Stdout)
log.Info("git pull error:", repo.GetGoPath(), result.Error)
log.Info("git pull error:", repo.GetGoPath(), result.Stdout)
}
}
@ -37,18 +37,18 @@ func doGitReset() {
if !argv.DoGitReset {
return
}
all := me.found.SortByGoPath()
all := me.found.SortByFullPath()
for all.Scan() {
repo := all.Next()
if me.forge.Config.IsReadOnly(repo.GoPath) {
// log.Info("is readonly", repo.GoPath)
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
// log.Info("is readonly", repo.GetGoPath())
if repo.CheckDirty() {
log.Info("is readonly and dirty", repo.GoPath)
log.Info("is readonly and dirty", repo.GetGoPath())
cmd := []string{"git", "reset", "--hard"}
repo.RunRealtime(cmd)
}
} else {
// log.Info("is not readonly", repo.GoPath)
// log.Info("is not readonly", repo.GetGoPath())
}
}
}
@ -57,14 +57,14 @@ func checkoutBranches(repo *gitpb.Repo) error {
dname := repo.GetDevelBranchName()
if dname == "" {
if err := me.forge.MakeDevelBranch(repo); err != nil {
log.Info("verify() no devel branch name", repo.GoPath)
log.Info("verify() no devel branch name", repo.GetGoPath())
return err
}
configSave = true
}
if repo.GetUserBranchName() == "" {
if err := me.forge.MakeUserBranch(repo); err != nil {
log.Info("verify() no devel branch name", repo.GoPath)
log.Info("verify() no devel branch name", repo.GetGoPath())
return err
}
configSave = true

View File

@ -4,7 +4,7 @@ package main
func doRedoGoMod() {
// me.forge.RillRedoGoMod()
all := me.forge.Repos.SortByGoPath()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if err := repo.ValidGoSum(); err == nil {

View File

@ -9,10 +9,10 @@ import (
func okExit(thing string) {
log.Info(thing, "ok")
if configSave {
me.forge.ConfigSave()
me.forge.SetConfigSave(configSave)
}
// log.Info("Finished go-clean on", check.GetGoPath(), "ok")
os.Exit(0)
me.forge.Exit()
}
func badExit(err error) {

View File

@ -35,10 +35,10 @@ func findRepos() bool {
}
func findPrivate() {
all := me.forge.Repos.SortByGoPath()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if me.forge.Config.IsPrivate(repo.GoPath) {
if me.forge.Config.IsPrivate(repo.GetGoPath()) {
me.found.AppendUniqueGoPath(repo)
}
}
@ -47,10 +47,10 @@ func findPrivate() {
// finds repos that are writable
func findMine() {
// log.Printf("get mine %s\n", me.forge.GetGoSrc())
all := me.forge.Repos.SortByGoPath()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if me.forge.Config.IsWritable(repo.GoPath) {
if me.forge.Config.IsWritable(repo.GetGoPath()) {
me.found.AppendUniqueGoPath(repo)
}
}
@ -59,25 +59,25 @@ func findMine() {
// finds repos that are writable
func findFavorites() {
// log.Printf("get favorites %s\n", me.forge.GetGoSrc())
all := me.forge.Repos.SortByGoPath()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if me.forge.Config.IsFavorite(repo.GoPath) {
if me.forge.Config.IsFavorite(repo.GetGoPath()) {
me.found.AppendUniqueGoPath(repo)
}
}
}
func findAll() {
all := me.forge.Repos.SortByGoPath()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
me.found.AppendUniqueGoPath(repo)
if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.FindReadOnly {
if me.forge.Config.IsReadOnly(repo.GetGoPath()) && !argv.FindReadOnly {
if repo.ReadOnly {
continue
}
log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GoPath)
log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GetGoPath())
repo.ReadOnly = true
configSave = true
continue

27
main.go
View File

@ -3,7 +3,6 @@ package main
// An app to submit patches for the 30 GO GUI repos
import (
"os"
"strings"
"go.wit.com/dev/alexflint/arg"
@ -19,6 +18,15 @@ var BUILDTIME string
// using this for now. triggers config save
var configSave bool
func getVersion(repo *gitpb.Repo, name string) string {
cmd := []string{"git", "describe", "--tags", "--always", name}
result := repo.RunQuiet(cmd)
output := strings.Join(result.Stdout, "\n")
log.Info("cmd =", cmd, output)
return strings.TrimSpace(output)
}
func main() {
me = new(mainType)
me.pp = arg.MustParse(&argv)
@ -29,6 +37,20 @@ func main() {
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
if configSave {
me.forge.ConfigSave()
configSave = false
}
/*
// var count int
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
verifyPrint(repo)
}
*/
if argv.Fix {
okExit("")
}
@ -37,7 +59,7 @@ func main() {
if argv.Config {
if findConfig() {
me.forge.ConfigPrintTable()
os.Exit(0)
okExit("")
}
} else {
findRepos()
@ -93,4 +115,5 @@ func main() {
// if nothing was selected, print out a table of them on STDOUT
doCobol()
}
okExit("")
}

View File

@ -57,7 +57,7 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
s.grid.NewButton("Update Patch Counts", func() {
var repocount, patchcount int
// broken after move to forge protobuf
all := me.forge.Repos.SortByGoPath()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if repo.GetReadOnly() {
@ -75,7 +75,7 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
repocount = 0
patchcount = 0
// broken after move to forge protobuf
all = me.forge.Repos.SortByGoPath()
all = me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if repo.GetReadOnly() {
@ -189,7 +189,7 @@ func (s *patchSummary) Update() {
var userT, develT, masterT int
// var userP, develP, masterP int
// broken after move to forge protobuf
all := me.forge.Repos.SortByGoPath()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
total += 1