return a map of the repos & errors

This commit is contained in:
Jeff Carr 2025-07-21 22:25:15 -05:00
parent b6a7af773d
commit 8e8d9e9a69
4 changed files with 20 additions and 28 deletions

View File

@ -145,6 +145,10 @@ func (f *Forge) InitPB() {
f.forgeURL = os.Getenv("FORGE_URL")
log.Info("got forge url", f.forgeURL)
}
// todo: play with these / determine good values based on user's machine
f.rillX = 10
f.rillY = 20
}
func (f *Forge) InitMachine() {

View File

@ -122,13 +122,6 @@ func (f *Forge) findMasterBranch(repo *gitpb.Repo) {
// TODO: figure out the name from git
repo.SetMasterBranchName("master")
/* no longer checkout on Init()
if repo.CheckoutMaster() {
} else {
cmd := []string{"git", "branch", "master"}
repo.Run(cmd)
}
*/
}
// figure out what the name of the git devel branch is
@ -137,13 +130,6 @@ func (f *Forge) findDevelBranch(repo *gitpb.Repo) {
// check the forge config first
if bname := f.Config.FindDevelBranch(repo.GetGoPath()); bname != "" {
repo.SetDevelBranchName(bname)
/* no longer checkout on Init()
if repo.CheckoutDevel() {
} else {
cmd := []string{"git", "branch", bname}
repo.Run(cmd)
}
*/
return
}
@ -153,13 +139,6 @@ func (f *Forge) findDevelBranch(repo *gitpb.Repo) {
}
repo.SetDevelBranchName("devel")
/* no longer checkout on Init()
if repo.CheckoutDevel() {
} else {
cmd := []string{"git", "branch", "devel"}
repo.Run(cmd)
}
*/
}
// this is still in flux

20
rill.go
View File

@ -150,13 +150,19 @@ func (f *Forge) RillFuncError(rillf func(*gitpb.Repo) error) int {
return counter
}
func (f *Forge) ConfigRill(rillX int, rillY int) {
}
// x is the size of the queued up pool (shouldn't matter here for this I think)
// y is how many simultanous functions will run
// todo: tune and compute x,y by # of CPUs and disk io
// todo: store x,y in forge config ? (or compute them. notsure)
func (f *Forge) RillRepo(rillX int, rillY int, rillf func(*gitpb.Repo) error) (int, error) {
var anyerr error
func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
var all []*gitpb.Repo
var allerr map[*gitpb.Repo]error
allerr = make(map[*gitpb.Repo]error)
for repo := range f.Repos.IterAll() {
if !repo.IsValidDir() {
log.Printf("%s %-50s", "got an invalid repo in forgepb.RillFuncError()", repo.GetGoPath())
@ -173,11 +179,11 @@ func (f *Forge) RillRepo(rillX int, rillY int, rillf func(*gitpb.Repo) error) (i
// Read users from the API.
// Concurrency = 20
dirs := rill.Map(ids, rillX, func(id *gitpb.Repo) (*gitpb.Repo, error) {
dirs := rill.Map(ids, f.rillX, func(id *gitpb.Repo) (*gitpb.Repo, error) {
return id, nil
})
rill.ForEach(dirs, rillY, func(repo *gitpb.Repo) error {
rill.ForEach(dirs, f.rillY, func(repo *gitpb.Repo) error {
meMu.Lock()
counter += 1
if counter > watch {
@ -186,10 +192,12 @@ func (f *Forge) RillRepo(rillX int, rillY int, rillf func(*gitpb.Repo) error) (i
}
meMu.Unlock()
if err := rillf(repo); err != nil {
anyerr = err
meMu.Lock()
allerr[repo] = err
meMu.Unlock()
}
return nil
})
return counter, anyerr
return allerr
}

View File

@ -22,7 +22,8 @@ type Forge struct {
fullscan time.Time // time of the last scan so it can be throttled
hostname string // your hostname
forgeURL string // URL to use to forge.wit.com
// Machine *zoopb.Machine // things for virtigo to track vm's
rillX int // used for Rill()
rillY int // used for Rill()
}
func (f *Forge) GetGoSrc() string {