Skip to content

Commit

Permalink
make boards details JSON output deterministic (#2419)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini authored Nov 14, 2023
1 parent 7a14663 commit 354464f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/cli/feedback/result/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package result
import (
"cmp"
"fmt"
"slices"

"github.com/arduino/arduino-cli/i18n"
f "github.com/arduino/arduino-cli/internal/algorithms"
Expand Down Expand Up @@ -425,6 +426,8 @@ func NewBoardDetailsResponse(b *rpc.BoardDetailsResponse) *BoardDetailsResponse
if b == nil {
return nil
}
buildProperties := b.GetBuildProperties()
slices.Sort(buildProperties)
return &BoardDetailsResponse{
Fqbn: b.GetFqbn(),
Name: b.GetName(),
Expand All @@ -440,7 +443,7 @@ func NewBoardDetailsResponse(b *rpc.BoardDetailsResponse) *BoardDetailsResponse
Programmers: NewProgrammers(b.GetProgrammers()),
DebuggingSupported: b.GetDebuggingSupported(),
IdentificationProperties: NewBoardIdentificationProperties(b.GetIdentificationProperties()),
BuildProperties: b.GetBuildProperties(),
BuildProperties: buildProperties,
DefaultProgrammerID: b.GetDefaultProgrammerId(),
}
}
Expand Down Expand Up @@ -636,6 +639,10 @@ func NewProgrammers(c []*rpc.Programmer) []*Programmer {
for i, v := range c {
res[i] = NewProgrammer(v)
}

slices.SortFunc(res, func(a, b *Programmer) int {
return cmp.Compare(a.Id, b.Id)
})
return res
}

Expand Down

0 comments on commit 354464f

Please sign in to comment.