work on a better/faster Reload()

This commit is contained in:
Jeff Carr 2025-09-13 00:52:44 -05:00
parent b21a47434e
commit bc9509e43b
5 changed files with 22 additions and 8 deletions

View File

@ -205,10 +205,10 @@ func (f *Forge) makeUserBranches() error {
}
func testReload(repo *gitpb.Repo) error {
if !repo.DidRepoChange() {
if !repo.HasChanged() {
return nil
}
repo.Reload()
repo.ReloadCheck()
return log.Errorf("repo changed")
}

View File

@ -92,6 +92,13 @@ func (f *Forge) Exit() {
if f.configSave {
f.ConfigSave()
}
if f.Repos != nil {
if config.HasChanged("repos") {
if err := f.Repos.ConfigSave(f.Config.ReposPB); err != nil {
log.Info("forge.Repos.ConfigSave() error", err)
}
}
}
// log.Info("forge.Exit() ok")
os.Exit(0)
}

View File

@ -35,7 +35,7 @@ func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
if f.Config.IsReadOnly(repo.GetGoPath()) {
repo.ReadOnly = true
}
repo.Reload()
repo.ReloadCheck()
return repo, nil
}
@ -52,7 +52,7 @@ func (f *Forge) AddNamespaceDir(ns string, fullpath string) (*gitpb.Repo, error)
}
f.VerifyBranchNames(repo)
repo.Reload()
repo.ReloadCheck()
// set the readonly flag based on the users' forge config
if f.Config.IsReadOnly(repo.GetGoPath()) {

14
rill.go
View File

@ -48,10 +48,10 @@ func (f *Forge) updateRepo(repo *gitpb.Repo) error {
return nil
}
if repo.DidRepoChange() {
if repo.HasChanged() {
f.configSave = true
// log.Info("repo changed ", repo.FullPath, repo.StateChange)
if err := repo.Reload(); err != nil {
if err := repo.ReloadCheck(); err != nil {
return err
}
} else {
@ -80,6 +80,9 @@ func (f *Forge) RillReload() int {
for repo := range f.Repos.IterAll() {
if !repo.IsValidDir() {
log.Printf("%s %-50s\n", "got an invalid repo in forgepb.RillReload()", repo.GetFullPath())
f.Repos.Delete(repo)
f.reposSave = true
log.Info("reposSave = true")
continue
}
all = append(all, repo)
@ -95,11 +98,11 @@ func (f *Forge) RillReload() int {
})
rill.ForEach(dirs, RillY, func(repo *gitpb.Repo) error {
if !repo.DidRepoChange() {
if !repo.HasChanged() {
return nil
}
f.configSave = true
repo.Reload()
repo.ReloadCheck()
counter += 1
return nil
})
@ -142,6 +145,9 @@ func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[string]*RillStats {
for repo := range f.Repos.IterAll() {
if !repo.IsValidDir() {
log.Printf("got an invalid repo in forgepb.RillRepos() %-50s\n", repo.GetFullPath())
f.Repos.Delete(repo)
f.reposSave = true
log.Info("reposSave = true")
continue
}
all = append(all, repo)

View File

@ -14,6 +14,7 @@ type Forge struct {
Repos *gitpb.Repos // the repo protobufs
Patchsets *Patchsets // patches that are in progress
configSave bool // if you need to save the config because things changed
reposSave bool // if you need to save the repos file
hostname string // your hostname
rillX int // used for Rill()
rillY int // used for Rill()