Skip to content

Commit a8c5dff

Browse files
apply CR suggestions
1 parent b37a73c commit a8c5dff

File tree

9 files changed

+87
-86
lines changed

9 files changed

+87
-86
lines changed

Diff for: commands/core.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.PlatformR
6363
}
6464
}
6565

66+
// This field make sense only if the platformRelease is installed otherwise is an "undefined behaviour"
67+
missingMetadata := platformRelease.IsInstalled() && !platformRelease.HasMetadata()
6668
return &rpc.PlatformRelease{
6769
Name: platformRelease.Name,
6870
Help: &rpc.HelpResources{Online: platformRelease.Platform.Package.Help.Online},
6971
Boards: boards,
7072
Version: platformRelease.Version.String(),
7173
Installed: platformRelease.IsInstalled(),
72-
MissingMetadata: !platformRelease.HasMetadata(),
74+
MissingMetadata: missingMetadata,
7375
Type: []string{platformRelease.Category},
7476
Deprecated: platformRelease.Deprecated,
7577
}

Diff for: commands/core/search_test.go

+56-67
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,20 @@ func TestPlatformSearch(t *testing.T) {
6161
},
6262
Releases: map[string]*rpc.PlatformRelease{
6363
"1.0.5": {
64-
Name: "RK002",
65-
Type: []string{"Contributed"},
66-
Installed: false,
67-
Version: "1.0.5",
68-
Boards: []*rpc.Board{{Name: "RK002"}},
69-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
70-
MissingMetadata: true,
64+
Name: "RK002",
65+
Type: []string{"Contributed"},
66+
Installed: false,
67+
Version: "1.0.5",
68+
Boards: []*rpc.Board{{Name: "RK002"}},
69+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
7170
},
7271
"1.0.6": {
73-
Name: "RK002",
74-
Type: []string{"Contributed"},
75-
Installed: false,
76-
Version: "1.0.6",
77-
Boards: []*rpc.Board{{Name: "RK002"}},
78-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
79-
MissingMetadata: true,
72+
Name: "RK002",
73+
Type: []string{"Contributed"},
74+
Installed: false,
75+
Version: "1.0.6",
76+
Boards: []*rpc.Board{{Name: "RK002"}},
77+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
8078
},
8179
},
8280
InstalledVersion: "",
@@ -103,13 +101,12 @@ func TestPlatformSearch(t *testing.T) {
103101
},
104102
Releases: map[string]*rpc.PlatformRelease{
105103
"1.0.6": {
106-
Name: "RK002",
107-
Type: []string{"Contributed"},
108-
Installed: false,
109-
Version: "1.0.6",
110-
Boards: []*rpc.Board{{Name: "RK002"}},
111-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
112-
MissingMetadata: true,
104+
Name: "RK002",
105+
Type: []string{"Contributed"},
106+
Installed: false,
107+
Version: "1.0.6",
108+
Boards: []*rpc.Board{{Name: "RK002"}},
109+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
113110
},
114111
},
115112
InstalledVersion: "",
@@ -136,22 +133,20 @@ func TestPlatformSearch(t *testing.T) {
136133
},
137134
Releases: map[string]*rpc.PlatformRelease{
138135
"1.0.5": {
139-
Name: "RK002",
140-
Type: []string{"Contributed"},
141-
Installed: false,
142-
Version: "1.0.5",
143-
Boards: []*rpc.Board{{Name: "RK002"}},
144-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
145-
MissingMetadata: true,
136+
Name: "RK002",
137+
Type: []string{"Contributed"},
138+
Installed: false,
139+
Version: "1.0.5",
140+
Boards: []*rpc.Board{{Name: "RK002"}},
141+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
146142
},
147143
"1.0.6": {
148-
Name: "RK002",
149-
Type: []string{"Contributed"},
150-
Installed: false,
151-
Version: "1.0.6",
152-
Boards: []*rpc.Board{{Name: "RK002"}},
153-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
154-
MissingMetadata: true,
144+
Name: "RK002",
145+
Type: []string{"Contributed"},
146+
Installed: false,
147+
Version: "1.0.6",
148+
Boards: []*rpc.Board{{Name: "RK002"}},
149+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
155150
},
156151
},
157152
InstalledVersion: "",
@@ -178,22 +173,20 @@ func TestPlatformSearch(t *testing.T) {
178173
},
179174
Releases: map[string]*rpc.PlatformRelease{
180175
"1.0.5": {
181-
Name: "RK002",
182-
Type: []string{"Contributed"},
183-
Installed: false,
184-
Version: "1.0.5",
185-
Boards: []*rpc.Board{{Name: "RK002"}},
186-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
187-
MissingMetadata: true,
176+
Name: "RK002",
177+
Type: []string{"Contributed"},
178+
Installed: false,
179+
Version: "1.0.5",
180+
Boards: []*rpc.Board{{Name: "RK002"}},
181+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
188182
},
189183
"1.0.6": {
190-
Name: "RK002",
191-
Type: []string{"Contributed"},
192-
Installed: false,
193-
Version: "1.0.6",
194-
Boards: []*rpc.Board{{Name: "RK002"}},
195-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
196-
MissingMetadata: true,
184+
Name: "RK002",
185+
Type: []string{"Contributed"},
186+
Installed: false,
187+
Version: "1.0.6",
188+
Boards: []*rpc.Board{{Name: "RK002"}},
189+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
197190
},
198191
},
199192
InstalledVersion: "",
@@ -220,22 +213,20 @@ func TestPlatformSearch(t *testing.T) {
220213
},
221214
Releases: map[string]*rpc.PlatformRelease{
222215
"1.0.5": {
223-
Name: "RK002",
224-
Type: []string{"Contributed"},
225-
Installed: false,
226-
Version: "1.0.5",
227-
Boards: []*rpc.Board{{Name: "RK002"}},
228-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
229-
MissingMetadata: true,
216+
Name: "RK002",
217+
Type: []string{"Contributed"},
218+
Installed: false,
219+
Version: "1.0.5",
220+
Boards: []*rpc.Board{{Name: "RK002"}},
221+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
230222
},
231223
"1.0.6": {
232-
Name: "RK002",
233-
Type: []string{"Contributed"},
234-
Installed: false,
235-
Version: "1.0.6",
236-
Boards: []*rpc.Board{{Name: "RK002"}},
237-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
238-
MissingMetadata: true,
224+
Name: "RK002",
225+
Type: []string{"Contributed"},
226+
Installed: false,
227+
Version: "1.0.6",
228+
Boards: []*rpc.Board{{Name: "RK002"}},
229+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
239230
},
240231
},
241232
InstalledVersion: "",
@@ -294,8 +285,7 @@ func TestPlatformSearch(t *testing.T) {
294285
{Name: "Arduino Industrial 101"},
295286
{Name: "Linino One"},
296287
},
297-
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
298-
MissingMetadata: true,
288+
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
299289
},
300290
},
301291
InstalledVersion: "",
@@ -354,8 +344,7 @@ func TestPlatformSearch(t *testing.T) {
354344
{Name: "Arduino Industrial 101"},
355345
{Name: "Linino One"},
356346
},
357-
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
358-
MissingMetadata: true,
347+
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
359348
},
360349
},
361350
InstalledVersion: "",

Diff for: docs/UPGRADING.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,12 @@ message PlatformRelease {
150150
// A URL provided by the author of the platform's package, intended to point
151151
// to their online help service.
152152
HelpResources help = 9;
153-
// This field is true when the platform is installed with the Arduino IDE 1.8.
154-
// If the platform is also not indexed it may fail to work correctly in some
155-
// circumstances, and it may need to be re-installed.
153+
// This field is true if the platform is missing installation metadata (this
154+
// happens if the platform has been installed with the legacy Arduino IDE
155+
// <=1.8.x). If the platform miss metadata and it's not indexed through a
156+
// package index, it may fail to work correctly in some circumstances, and it
157+
// may need to be reinstalled. This should be evaluated only when the
158+
// PlatformRelease is `Installed` otherwise is an undefined behaviour.
156159
bool missing_metadata = 10;
157160
// True this release is deprecated
158161
bool deprecated = 11;

Diff for: internal/cli/arguments/completion.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ func GetUninstallableCores() []string {
127127
inst := instance.CreateAndInit()
128128

129129
platforms, _ := core.PlatformSearch(&rpc.PlatformSearchRequest{
130-
Instance: inst,
131-
AllVersions: false,
130+
Instance: inst,
131+
AllVersions: false,
132+
ManuallyInstalled: true,
132133
})
133134

134135
var res []string

Diff for: internal/cli/core/list.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ func GetList(inst *rpc.Instance, all bool, updatableOnly bool) []*rpc.PlatformSu
7070
feedback.Fatal(tr("Error listing platforms: %v", err), feedback.ErrGeneric)
7171
}
7272

73+
// If both `all` and `updatableOnly` are set, `all` takes precedence.
74+
if all {
75+
return platforms.GetSearchOutput()
76+
}
77+
7378
result := []*rpc.PlatformSummary{}
7479
for _, platform := range platforms.GetSearchOutput() {
75-
// If both `all` and `updatableOnly` are set, `all` takes precedence.
76-
if all {
77-
result = append(result, platform)
78-
continue
79-
}
8080
if platform.InstalledVersion == "" && !platform.GetMetadata().ManuallyInstalled {
8181
continue
8282
}

Diff for: internal/integrationtest/board/hardware_loading_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ func TestHardwareLoading(t *testing.T) {
188188
"releases": {
189189
"9.9.9": {
190190
"name": "My AVR Boards",
191-
"missing_metadata": true,
192191
"boards": [
193192
{
194193
"name": "Arduino Yún",
@@ -210,7 +209,6 @@ func TestHardwareLoading(t *testing.T) {
210209
"manually_installed": true,
211210
"releases": {
212211
"9.9.9": {
213-
"missing_metadata": true
214212
}
215213
}
216214
}

Diff for: internal/integrationtest/core/core_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ func TestCoreSearchNoArgs(t *testing.T) {
199199
stdout, _, err = cli.Run("core", "search", "--format", "json", "--additional-urls="+url.String())
200200
require.NoError(t, err)
201201
requirejson.Contains(t, stdout, `[{"id": "test:x86", "releases": { "3.0.0": {"name":"test_core"}}}]`)
202+
// A platform could contain multiple releases, we get the length of how many releases are present for each platform
203+
// and we sum them to see if the expected numers matches.
202204
requirejson.Query(t, stdout, `[.[].releases | length] | add`, fmt.Sprint(numPlatforms))
203205
}
204206

Diff for: rpc/cc/arduino/cli/commands/v1/common.pb.go

+6-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: rpc/cc/arduino/cli/commands/v1/common.proto

+6-3
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ message PlatformRelease {
132132
// A URL provided by the author of the platform's package, intended to point
133133
// to their online help service.
134134
HelpResources help = 9;
135-
// This field is true when the platform is installed with the Arduino IDE 1.8.
136-
// If the platform is also not indexed it may fail to work correctly in some
137-
// circumstances, and it may need to be re-installed.
135+
// This field is true if the platform is missing installation metadata (this
136+
// happens if the platform has been installed with the legacy Arduino IDE
137+
// <=1.8.x). If the platform miss metadata and it's not indexed through a
138+
// package index, it may fail to work correctly in some circumstances, and it
139+
// may need to be reinstalled. This should be evaluated only when the
140+
// PlatformRelease is `Installed` otherwise is an undefined behaviour.
138141
bool missing_metadata = 10;
139142
// True this release is deprecated
140143
bool deprecated = 11;

0 commit comments

Comments
 (0)