detect repos to update

This commit is contained in:
Jeff Carr 2025-07-08 15:48:22 -05:00
parent 807049f6c7
commit 0dea6a2553
3 changed files with 47 additions and 2 deletions

View File

@ -60,4 +60,5 @@ devel:
pull: install
forge pull dirty
FORGE_URL="http://forge.grid.wit.com:2520/" forge pull
# forge pull patches

View File

@ -121,6 +121,19 @@ func findAll() *gitpb.Repos {
return found
}
func find50() *gitpb.Repos {
count := 0
found := gitpb.NewRepos()
for repo := range me.forge.Repos.IterByFullPath() {
found.AppendByGoPath(repo)
if count > 50 {
return found
}
count += 1
}
return found
}
func findUser() *gitpb.Repos {
found := gitpb.NewRepos()

View File

@ -72,15 +72,46 @@ func doGitPullNew() error {
}
if check.Len() == 0 {
check = doFind()
// check = doFind()
check = findAll()
// check = find50()
// check = findMine()
}
me.forge.PrintHumanTableFull(check)
found, err := me.forge.LookupPB(check)
if err != nil {
log.Info("LookupPB() failed", err, "len(check)=", check.Len())
return err
}
// me.forge.PrintHumanTableFull(found)
// check to see if the repos need to be updated
update := gitpb.NewRepos()
for repo := range found.IterAll() {
a := repo.GetLocalHash(repo.GetMasterBranchName())
ns := repo.GetNamespace()
repo2 := me.forge.Repos.FindByNamespace(ns)
if repo2 == nil {
log.Info("repo namespace does not exist", a, repo.Namespace)
continue
}
b := repo2.GetLocalHash(repo2.GetMasterBranchName())
if b == a {
continue
}
log.Info(a, "!=", b, repo.Namespace)
update.AppendByNamespace(repo2)
}
if update.Len() == 0 {
// nothing to update
return nil
}
if _, err := me.forge.UpdatePB(update); err != nil {
log.Info("UpdatePB() failed", err, "len(check)=", update.Len())
return err
}
me.forge.PrintHumanTableFull(found)
return nil
}