work on a new repo Scan() function

This commit is contained in:
Jeff Carr 2025-09-13 05:32:19 -05:00
parent 72d728d4e7
commit f4d60d1fb9
4 changed files with 31 additions and 71 deletions

View File

@ -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

View File

@ -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())

View File

@ -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

View File

@ -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()