diff options
Diffstat (limited to 'internal/rosa/state.go')
| -rw-r--r-- | internal/rosa/state.go | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/internal/rosa/state.go b/internal/rosa/state.go index 6ff6f1cf..7cdf7cb5 100644 --- a/internal/rosa/state.go +++ b/internal/rosa/state.go @@ -384,14 +384,14 @@ func (s *S) mustRegister( }) } -// Count returns the number of [Artifact] registered to s. -func (s *S) Count() int { +// count returns the number of [Artifact] registered to s. +func (s *S) count() int { return int(s.artifactCount.Load()) } -// Collect returns all [ArtifactH] registered to s. -func (s *S) Collect() (handles P) { - handles = make(P, 0, s.Count()) +// CollectAll returns all [ArtifactH] registered to s. +func (s *S) CollectAll() (handles P) { + handles = make(P, 0, s.count()) s.artifacts.Range(func(key, _ any) bool { handles = append(handles, key.(ArtifactH)) return true @@ -402,6 +402,23 @@ func (s *S) Collect() (handles P) { return } +// Collect returns all non-excluded [ArtifactH] registered to s. +func (s *S) Collect() (handles P) { + handles = make(P, 0, s.count()) + s.artifacts.Range(func(key, _ any) bool { + h := key.(ArtifactH) + meta, _ := s.Std().MustLoad(h) + if !meta.Exclude { + handles = append(handles, h) + } + return true + }) + slices.SortFunc(handles, func(a, b ArtifactH) int { + return strings.Compare(a.String(), b.String()) + }) + return +} + // deferredGit is a call to Toolchain.newTagRemote from azalea. type deferredGit struct { url string @@ -915,6 +932,7 @@ func (ctx *evalContext) pf( k("description"): &meta.Description, k("website"): &meta.Website, k("version"): &meta.Version, + k("exclude"): &meta.Exclude, k("anitya"): &anitya, k("latest"): &meta.latest, |
