From be1ecced164e53740c8e0326aefddace2123a5bd Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Mon, 16 Oct 2023 17:01:51 +0200 Subject: [PATCH] apply CR suggestions --- commands/core.go | 4 +++- docs/UPGRADING.md | 9 ++++++--- internal/cli/arguments/completion.go | 5 +++-- internal/cli/core/list.go | 10 +++++----- .../integrationtest/board/hardware_loading_test.go | 2 -- internal/integrationtest/core/core_test.go | 2 ++ rpc/cc/arduino/cli/commands/v1/common.pb.go | 9 ++++++--- rpc/cc/arduino/cli/commands/v1/common.proto | 9 ++++++--- 8 files changed, 31 insertions(+), 19 deletions(-) diff --git a/commands/core.go b/commands/core.go index 6bd17d0fcec..14dc3360e4c 100644 --- a/commands/core.go +++ b/commands/core.go @@ -63,13 +63,15 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.PlatformR } } + // This field make sense only if the platformRelease is installed otherwise is an "undefined behaviour" + missingMetadata := platformRelease.IsInstalled() && !platformRelease.HasMetadata() return &rpc.PlatformRelease{ Name: platformRelease.Name, Help: &rpc.HelpResources{Online: platformRelease.Platform.Package.Help.Online}, Boards: boards, Version: platformRelease.Version.String(), Installed: platformRelease.IsInstalled(), - MissingMetadata: !platformRelease.HasMetadata(), + MissingMetadata: missingMetadata, Type: []string{platformRelease.Category}, Deprecated: platformRelease.Deprecated, } diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index d11eb69bf01..d26dd4fd73f 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -150,9 +150,12 @@ message PlatformRelease { // A URL provided by the author of the platform's package, intended to point // to their online help service. HelpResources help = 9; - // This field is true when the platform is installed with the Arduino IDE 1.8. - // If the platform is also not indexed it may fail to work correctly in some - // circumstances, and it may need to be re-installed. + // This field is true if the platform is missing installation metadata (this + // happens if the platform has been installed with the legacy Arduino IDE + // <=1.8.x). If the platform miss metadata and it's not indexed through a + // package index, it may fail to work correctly in some circumstances, and it + // may need to be reinstalled. This should be evaluated only when the + // PlatformRelease is `Installed` otherwise is an undefined behaviour. bool missing_metadata = 10; // True this release is deprecated bool deprecated = 11; diff --git a/internal/cli/arguments/completion.go b/internal/cli/arguments/completion.go index cf94e027381..692c9dc3c7a 100644 --- a/internal/cli/arguments/completion.go +++ b/internal/cli/arguments/completion.go @@ -127,8 +127,9 @@ func GetUninstallableCores() []string { inst := instance.CreateAndInit() platforms, _ := core.PlatformSearch(&rpc.PlatformSearchRequest{ - Instance: inst, - AllVersions: false, + Instance: inst, + AllVersions: false, + ManuallyInstalled: true, }) var res []string diff --git a/internal/cli/core/list.go b/internal/cli/core/list.go index 74922cbd0c4..4242fa6d7a9 100644 --- a/internal/cli/core/list.go +++ b/internal/cli/core/list.go @@ -70,13 +70,13 @@ func GetList(inst *rpc.Instance, all bool, updatableOnly bool) []*rpc.PlatformSu feedback.Fatal(tr("Error listing platforms: %v", err), feedback.ErrGeneric) } + // If both `all` and `updatableOnly` are set, `all` takes precedence. + if all { + return platforms.GetSearchOutput() + } + result := []*rpc.PlatformSummary{} for _, platform := range platforms.GetSearchOutput() { - // If both `all` and `updatableOnly` are set, `all` takes precedence. - if all { - result = append(result, platform) - continue - } if platform.InstalledVersion == "" && !platform.GetMetadata().ManuallyInstalled { continue } diff --git a/internal/integrationtest/board/hardware_loading_test.go b/internal/integrationtest/board/hardware_loading_test.go index 902a6aa3bd6..9b2a6d44e10 100644 --- a/internal/integrationtest/board/hardware_loading_test.go +++ b/internal/integrationtest/board/hardware_loading_test.go @@ -188,7 +188,6 @@ func TestHardwareLoading(t *testing.T) { "releases": { "9.9.9": { "name": "My AVR Boards", - "missing_metadata": true, "boards": [ { "name": "Arduino Yún", @@ -210,7 +209,6 @@ func TestHardwareLoading(t *testing.T) { "manually_installed": true, "releases": { "9.9.9": { - "missing_metadata": true } } } diff --git a/internal/integrationtest/core/core_test.go b/internal/integrationtest/core/core_test.go index d0b7508a4e1..c5762d3beb6 100644 --- a/internal/integrationtest/core/core_test.go +++ b/internal/integrationtest/core/core_test.go @@ -199,6 +199,8 @@ func TestCoreSearchNoArgs(t *testing.T) { stdout, _, err = cli.Run("core", "search", "--format", "json", "--additional-urls="+url.String()) require.NoError(t, err) requirejson.Contains(t, stdout, `[{"id": "test:x86", "releases": { "3.0.0": {"name":"test_core"}}}]`) + // A platform could contain multiple releases, we get the length of how many releases are present for each platform + // and we sum them to see if the expected numers matches. requirejson.Query(t, stdout, `[.[].releases | length] | add`, fmt.Sprint(numPlatforms)) } diff --git a/rpc/cc/arduino/cli/commands/v1/common.pb.go b/rpc/cc/arduino/cli/commands/v1/common.pb.go index c18b0178241..5a1302920a0 100644 --- a/rpc/cc/arduino/cli/commands/v1/common.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/common.pb.go @@ -752,9 +752,12 @@ type PlatformRelease struct { // A URL provided by the author of the platform's package, intended to point // to their online help service. Help *HelpResources `protobuf:"bytes,9,opt,name=help,proto3" json:"help,omitempty"` - // This field is true when the platform is installed with the Arduino IDE 1.8. - // If the platform is also not indexed it may fail to work correctly in some - // circumstances, and it may need to be re-installed. + // This field is true if the platform is missing installation metadata (this + // happens if the platform has been installed with the legacy Arduino IDE + // <=1.8.x). If the platform miss metadata and it's not indexed through a + // package index, it may fail to work correctly in some circumstances, and it + // may need to be reinstalled. This should be evaluated only when the + // PlatformRelease is `Installed` otherwise is an undefined behaviour. MissingMetadata bool `protobuf:"varint,10,opt,name=missing_metadata,json=missingMetadata,proto3" json:"missing_metadata,omitempty"` // True this release is deprecated Deprecated bool `protobuf:"varint,11,opt,name=deprecated,proto3" json:"deprecated,omitempty"` diff --git a/rpc/cc/arduino/cli/commands/v1/common.proto b/rpc/cc/arduino/cli/commands/v1/common.proto index f69d500622b..f81816d7a46 100644 --- a/rpc/cc/arduino/cli/commands/v1/common.proto +++ b/rpc/cc/arduino/cli/commands/v1/common.proto @@ -132,9 +132,12 @@ message PlatformRelease { // A URL provided by the author of the platform's package, intended to point // to their online help service. HelpResources help = 9; - // This field is true when the platform is installed with the Arduino IDE 1.8. - // If the platform is also not indexed it may fail to work correctly in some - // circumstances, and it may need to be re-installed. + // This field is true if the platform is missing installation metadata (this + // happens if the platform has been installed with the legacy Arduino IDE + // <=1.8.x). If the platform miss metadata and it's not indexed through a + // package index, it may fail to work correctly in some circumstances, and it + // may need to be reinstalled. This should be evaluated only when the + // PlatformRelease is `Installed` otherwise is an undefined behaviour. bool missing_metadata = 10; // True this release is deprecated bool deprecated = 11;