Skip to content

Commit ff2623d

Browse files
committed
Rename Latest IndexBoard field to LatestFirmware
1 parent a21b6a3 commit ff2623d

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

cli/firmware/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func list(fqbn string) {
7171
BoardFQBN: board.Fqbn,
7272
Module: board.Module,
7373
FirmwareVersion: firmware.Version,
74-
Latest: board.Latest == firmware,
74+
Latest: board.LatestFirmware == firmware,
7575
})
7676
}
7777
}

indexes/firmwareindex/firmwareindex.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package firmwareindex
2222
import (
2323
"encoding/json"
2424
"runtime"
25-
"sort"
2625

2726
"github.com/arduino/arduino-cli/arduino/security"
2827
"github.com/arduino/go-paths-helper"
@@ -48,7 +47,7 @@ type IndexBoard struct {
4847
UploadTouch bool `json:"upload.use_1200bps_touch"`
4948
UploadWait bool `json:"upload.wait_for_upload_port"`
5049
UploaderCommand *IndexUploaderCommand `json:"uploader.command,required"`
51-
Latest *IndexFirmware `json:"-"`
50+
LatestFirmware *IndexFirmware `json:"-"`
5251
}
5352

5453
type IndexUploaderCommand struct {
@@ -122,30 +121,19 @@ func LoadIndexNoSign(jsonIndexFile *paths.Path) (*Index, error) {
122121
// Determine latest firmware for each board
123122
for _, board := range index.Boards {
124123
if board.Module == "SARA" {
125-
// TODO implement?? by defualt you have to specify the version
124+
// TODO implement?? by default you have to specify the version
126125
continue
127126
}
128127
for _, firmware := range board.Firmwares {
129-
if board.Latest == nil || firmware.Version.GreaterThan(board.Latest.Version) {
130-
board.Latest = firmware
128+
if board.LatestFirmware == nil || firmware.Version.GreaterThan(board.LatestFirmware.Version) {
129+
board.LatestFirmware = firmware
131130
}
132131
}
133132
}
134133

135134
return &index, nil
136135
}
137136

138-
// GetLatestFirmware returns the specified IndexFirmware version for this board.
139-
// Returns nil if version is not found.
140-
func (b *IndexBoard) GetFirmware(version string) *IndexFirmware {
141-
for _, firmware := range b.Firmwares {
142-
if firmware.Version == version {
143-
return firmware
144-
}
145-
}
146-
return nil
147-
}
148-
149137
// GetBoard returns the IndexBoard for the given FQBN
150138
func (i *Index) GetBoard(fqbn string) *IndexBoard {
151139
for _, b := range i.Boards {
@@ -156,6 +144,18 @@ func (i *Index) GetBoard(fqbn string) *IndexBoard {
156144
return nil
157145
}
158146

147+
// GetLatestFirmware returns the specified IndexFirmware version for this board.
148+
// Returns nil if version is not found.
149+
func (b *IndexBoard) GetFirmware(version string) *IndexFirmware {
150+
v := semver.ParseRelaxed(version)
151+
for _, firmware := range b.Firmwares {
152+
if firmware.Version.Equal(v) {
153+
return firmware
154+
}
155+
}
156+
return nil
157+
}
158+
159159
func (b *IndexBoard) GetUploaderCommand() string {
160160
if runtime.GOOS == "windows" && b.UploaderCommand.Windows != "" {
161161
return b.UploaderCommand.Linux

0 commit comments

Comments
 (0)