From 6b6f7a1fad85ec0ffd26b4ecbb24b1446b4c6d48 Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Tue, 14 Nov 2023 11:16:16 +0100 Subject: [PATCH] make boards details JSON output deterministic --- internal/cli/feedback/result/rpc.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/cli/feedback/result/rpc.go b/internal/cli/feedback/result/rpc.go index 92f2d7e6fdb..82e172f329d 100644 --- a/internal/cli/feedback/result/rpc.go +++ b/internal/cli/feedback/result/rpc.go @@ -18,6 +18,7 @@ package result import ( "cmp" "fmt" + "slices" "github.com/arduino/arduino-cli/i18n" f "github.com/arduino/arduino-cli/internal/algorithms" @@ -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(), @@ -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(), } } @@ -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 }