summaryrefslogtreecommitdiff
path: root/iterByMode.go
blob: f3113a4d44a9fcf2e79c757e3eae6cb8293da94a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package forgepb

import (
	"iter"
	"strings"

	"go.wit.com/lib/protobuf/gitpb"
)

func (f *Forge) IterByMode() iter.Seq[*gitpb.Repo] {
	if f == nil {
		panic("forge is not initialized")
	}
	repos := gitpb.NewRepos()
	if f.mode == ForgeMode_NORMAL {
		for r := range f.Repos.IterAll() {
			if !strings.HasPrefix(r.Namespace, "go.wit.com") {
				continue
			}
			repos.Append(r)
		}
		return repos.IterByNamespace()
	}
	return f.Repos.IterAll()
}