Skip to content

Commit 17371e8

Browse files
apply CR suggestions
1 parent b37a73c commit 17371e8

File tree

9 files changed

+31
-30
lines changed

9 files changed

+31
-30
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

-11
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func TestPlatformSearch(t *testing.T) {
6767
Version: "1.0.5",
6868
Boards: []*rpc.Board{{Name: "RK002"}},
6969
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
70-
MissingMetadata: true,
7170
},
7271
"1.0.6": {
7372
Name: "RK002",
@@ -76,7 +75,6 @@ func TestPlatformSearch(t *testing.T) {
7675
Version: "1.0.6",
7776
Boards: []*rpc.Board{{Name: "RK002"}},
7877
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
79-
MissingMetadata: true,
8078
},
8179
},
8280
InstalledVersion: "",
@@ -109,7 +107,6 @@ func TestPlatformSearch(t *testing.T) {
109107
Version: "1.0.6",
110108
Boards: []*rpc.Board{{Name: "RK002"}},
111109
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
112-
MissingMetadata: true,
113110
},
114111
},
115112
InstalledVersion: "",
@@ -142,7 +139,6 @@ func TestPlatformSearch(t *testing.T) {
142139
Version: "1.0.5",
143140
Boards: []*rpc.Board{{Name: "RK002"}},
144141
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
145-
MissingMetadata: true,
146142
},
147143
"1.0.6": {
148144
Name: "RK002",
@@ -151,7 +147,6 @@ func TestPlatformSearch(t *testing.T) {
151147
Version: "1.0.6",
152148
Boards: []*rpc.Board{{Name: "RK002"}},
153149
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
154-
MissingMetadata: true,
155150
},
156151
},
157152
InstalledVersion: "",
@@ -184,7 +179,6 @@ func TestPlatformSearch(t *testing.T) {
184179
Version: "1.0.5",
185180
Boards: []*rpc.Board{{Name: "RK002"}},
186181
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
187-
MissingMetadata: true,
188182
},
189183
"1.0.6": {
190184
Name: "RK002",
@@ -193,7 +187,6 @@ func TestPlatformSearch(t *testing.T) {
193187
Version: "1.0.6",
194188
Boards: []*rpc.Board{{Name: "RK002"}},
195189
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
196-
MissingMetadata: true,
197190
},
198191
},
199192
InstalledVersion: "",
@@ -226,7 +219,6 @@ func TestPlatformSearch(t *testing.T) {
226219
Version: "1.0.5",
227220
Boards: []*rpc.Board{{Name: "RK002"}},
228221
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
229-
MissingMetadata: true,
230222
},
231223
"1.0.6": {
232224
Name: "RK002",
@@ -235,7 +227,6 @@ func TestPlatformSearch(t *testing.T) {
235227
Version: "1.0.6",
236228
Boards: []*rpc.Board{{Name: "RK002"}},
237229
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
238-
MissingMetadata: true,
239230
},
240231
},
241232
InstalledVersion: "",
@@ -295,7 +286,6 @@ func TestPlatformSearch(t *testing.T) {
295286
{Name: "Linino One"},
296287
},
297288
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
298-
MissingMetadata: true,
299289
},
300290
},
301291
InstalledVersion: "",
@@ -355,7 +345,6 @@ func TestPlatformSearch(t *testing.T) {
355345
{Name: "Linino One"},
356346
},
357347
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
358-
MissingMetadata: true,
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)