Skip to content

Commit

Permalink
Merge pull request #7 from grafana/6-fix-detection-of-new-extensions
Browse files Browse the repository at this point in the history
fix detection of new extensions
  • Loading branch information
szkiba authored Oct 8, 2024
2 parents 93908f3 + 6eacddf commit 4b38122
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 278 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/distro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
fi
- name: Build Distro
uses: grafana/[email protected].5
uses: grafana/[email protected].6
if: ${{ steps.latest.outputs.today != 'true' }}
id: build
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/dist
/recent.json
/k6dist
/k6dist
/coverage.txt
272 changes: 0 additions & 272 deletions coverage.txt

This file was deleted.

24 changes: 20 additions & 4 deletions internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ func loadRegistryHTTP(ctx context.Context, source string) (Registry, error) {

// AddLatest adds latest versions to extensions.
func (reg Registry) AddLatest(modules Modules) bool {
dict := make(map[string]*Extension, len(reg))
regAsMap := make(map[string]*Extension, len(reg))

for idx := range reg {
dict[reg[idx].Module] = &reg[idx]
regAsMap[reg[idx].Module] = &reg[idx]
}

changed := false

for _, mod := range modules {
ext, found := dict[mod.Path]
ext, found := regAsMap[mod.Path]
if found {
ext.Versions[1] = mod.Version
changed = changed || (ext.Versions[0] != mod.Version)
Expand All @@ -127,5 +127,21 @@ func (reg Registry) AddLatest(modules Modules) bool {
changed = changed || !found
}

return changed
if changed {
return true
}

modulesAsMap := make(map[string]*Module, len(modules))

for idx := range modules {
modulesAsMap[modules[idx].Path] = &modules[idx]
}

for _, ext := range reg {
if _, found := modulesAsMap[ext.Module]; !found {
panic("ok")
}
}

return false
}
5 changes: 5 additions & 0 deletions releases/v0.1.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
🎉 k6dist `v0.1.6` is here!

**Fix detection of new extensions**

Change detection now correctly detects new extensions released since the previous release.

0 comments on commit 4b38122

Please sign in to comment.