summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-13 00:52:44 -0500
committerJeff Carr <[email protected]>2025-09-13 00:52:44 -0500
commitbc9509e43b3a0cbf24e3e354ffb840f4fdffe6b3 (patch)
tree595d299265c1654bf5d04b41b17c22f3979a40ba
parentb21a47434e2806d7cfb882e319f9fd5a5d9867d8 (diff)
work on a better/faster Reload()
-rw-r--r--branches.go4
-rw-r--r--init.go7
-rw-r--r--repoNew.go4
-rw-r--r--rill.go14
-rw-r--r--structs.go1
5 files changed, 22 insertions, 8 deletions
diff --git a/branches.go b/branches.go
index 2f72127..a503a96 100644
--- a/branches.go
+++ b/branches.go
@@ -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")
}
diff --git a/init.go b/init.go
index 6446775..49f04a0 100644
--- a/init.go
+++ b/init.go
@@ -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)
}
diff --git a/repoNew.go b/repoNew.go
index 3a80511..db21181 100644
--- a/repoNew.go
+++ b/repoNew.go
@@ -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()) {
diff --git a/rill.go b/rill.go
index 2a1e8ac..882bc3a 100644
--- a/rill.go
+++ b/rill.go
@@ -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)
diff --git a/structs.go b/structs.go
index 08aa464..470a843 100644
--- a/structs.go
+++ b/structs.go
@@ -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()