From f4d60d1fb952697c9de93534572d0aa108aa6506 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 13 Sep 2025 05:32:19 -0500 Subject: [PATCH] work on a new repo Scan() function --- applyPatch.go | 70 ------------------------------------------------ doNormal.go | 5 ++++ helperPatches.go | 18 +++++++++++++ main.go | 9 ++++++- 4 files changed, 31 insertions(+), 71 deletions(-) diff --git a/applyPatch.go b/applyPatch.go index 626a582..18077c9 100644 --- a/applyPatch.go +++ b/applyPatch.go @@ -12,39 +12,6 @@ func savePatchset(pset *forgepb.Patchset) error { log.Info("savePatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail()) log.Info("savePatches() Branch Name", pset.GetStartBranchName()) log.Info("savePatches() Start Hash", pset.GetStartBranchHash()) - - var count int - var bad int - var lasterr error - all := pset.Patches.SortByFilename() - for all.Scan() { - p := all.Next() - basedir := filepath.Join(os.Getenv("FORGE_CONFIG"), "currentpatches") - if fullname, err := savePatchFile(p, basedir); err != nil { - log.Info(fullname, "save failed", err) - bad += 1 - lasterr = err - } - count += 1 - } - log.Info("pset has", count, "total patches, ", bad, "bad save patches") - if bad == 0 { - return lasterr - } - return nil -} -*/ - -/* -// re-run git CheckDirty() on everything -func IsAnythingDirty() bool { - doCheckDirtyAndConfigSave() - found := me.forge.FindDirty() - if found.Len() == 0 { - return false - } else { - return true - } } */ @@ -62,43 +29,6 @@ func countCurrentPatches(repo *gitpb.Repo) int { return len(result.Stdout) } -func savePatchFile(p *forgepb.Patch, basedir string) (string, error) { - basepath, filename := filepath.Split(p.Filename) - fulldir := filepath.Join(basedir, basepath) - err := os.MkdirAll(fulldir, os.ModePerm) - if err != nil { - log.Info("applyPathces() MkdirAll failed for", fulldir) - log.Info("applyPathces() MkdirAll failed err", err) - return "", err - } - tmpname := filepath.Join(fulldir, filename) - log.Info("pset filename FILENAME IS REAL?", tmpname) - raw, _ := os.OpenFile(tmpname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) - raw.Write(p.Data) - raw.Close() - return tmpname, nil -} - -func readPatchFile(pbfile string) (*forgepb.Patchset, error) { - bytes, err := os.ReadFile(pbfile) - if err != nil { - log.Info("readfile error", pbfile, err) - return nil, err - } - return handleBytes(bytes) -} - -func handleBytes(bytes []byte) (*forgepb.Patchset, error) { - var pset *forgepb.Patchset - pset = new(forgepb.Patchset) - err := pset.Unmarshal(bytes) - if err != nil { - log.Info("Unmarshal failed", err) - return nil, err - } - return pset, nil -} - func doRegister(newurl string) error { var url string url = me.urlbase + "/register?url=" + newurl diff --git a/doNormal.go b/doNormal.go index 964c8ab..4c773d0 100644 --- a/doNormal.go +++ b/doNormal.go @@ -61,6 +61,11 @@ func checkNormalRepoState(repo *gitpb.Repo) error { if repo.GetUserBranchName() == "" { return log.Errorf("user branch name blank") } + if repo.GetGoPath() == repo.GetNamespace() { + // log.Info(repo.FullPath, "gopath == namespace", repo.GetGoPath(), repo.GetNamespace()) + } else { + log.Info(repo.FullPath, "gopath != namespace", repo.GetGoPath(), repo.GetNamespace()) + } repo.MakeLocalDevelBranch() repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) diff --git a/helperPatches.go b/helperPatches.go index 19fdc62..24a6617 100644 --- a/helperPatches.go +++ b/helperPatches.go @@ -12,9 +12,27 @@ import ( "strings" "go.wit.com/lib/protobuf/forgepb" + "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) +func makeReposTablePB(pb *gitpb.Repos) *gitpb.ReposTable { + t := pb.NewTable("quickListRepos") + t.NewUuid() + + sf := t.AddStringFunc("Namespace", func(r *gitpb.Repo) string { + return r.GetNamespace() + }) + sf.Width = 16 + + userVer := t.AddStringFunc("user", func(repo *gitpb.Repo) string { + ver := repo.GetUserVersion() + return ver + }) + userVer.Width = 4 + return t +} + /* type stdPatchsetTableWin struct { sync.Mutex diff --git a/main.go b/main.go index 6c02138..4a9619c 100644 --- a/main.go +++ b/main.go @@ -59,8 +59,15 @@ func main() { me.pp = arg.MustParse(&argv) me.forge = forgepb.Init() + + if argv.Force { + me.forge.TestScan() + doNormal() + okExit("") + } + // me.forge.RillRepos(reloadCheck) - me.forge.ScanGoSrc() + // me.forge.ScanGoSrc() // initialize patches doPatchInit()