From ee7e8d5b2ba38bcc53b210c9a04ccff0de4a4f19 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 17 Dec 2024 06:37:00 -0600 Subject: lots of changes in gitpb --- init.go | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'init.go') diff --git a/init.go b/init.go index 4ece518..4cbaa16 100644 --- a/init.go +++ b/init.go @@ -29,9 +29,9 @@ func Init() *Forge { f.ScanGoSrc() end := f.Repos.Len() if (end - start) == 0 { - log.Info("forgepb.Scan() Scan did not find new git repositories.") + log.Info("forgepb.Scan() Scan did not find new git repositories. Total =", end) } else { - log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.") + log.Info("forgepb.Scan() Scan found", end-start, "new git repositories. Total =", end) } f.updateAll() @@ -50,8 +50,8 @@ func (f *Forge) updateAll() { repo := all.Next() if !repo.IsValidDir() { - log.Printf("%10s %-50s", "old?\n", repo.GoPath) - f.Repos.DeleteByGoPath(repo.GoPath) + log.Printf("%10s %-50s", "bad git dir\n", repo.FullPath) + f.Repos.DeleteByFullPath(repo.FullPath) f.configSave = true continue } @@ -61,6 +61,14 @@ func (f *Forge) updateAll() { log.Info("repo changed", repo.StateChange, repo.FullPath) repo.Reload() } + if f.Config.IsReadOnly(repo.GetGoPath()) { + if repo.ReadOnly { + } else { + log.Info("readonly flag on repo is wrong", repo.GetGoPath()) + repo.ReadOnly = true + f.configSave = true + } + } } } @@ -109,3 +117,17 @@ func InitPB() *Forge { f.Repos.ConfigLoad() return f } + +func (f *Forge) SetConfigSave(b bool) { + f.configSave = b +} + +// saves the config if there have been changes +func (f *Forge) Exit() { + log.Info("forge.configSave =", f.configSave) + if f.configSave { + f.ConfigSave() + } + log.Info("forge.Exit() ok") + os.Exit(0) +} -- cgit v1.2.3