Skip to content

Commit

Permalink
apply CR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Oct 16, 2023
1 parent b37a73c commit be1ecce
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 19 deletions.
4 changes: 3 additions & 1 deletion commands/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
9 changes: 6 additions & 3 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions internal/cli/arguments/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions internal/integrationtest/board/hardware_loading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -210,7 +209,6 @@ func TestHardwareLoading(t *testing.T) {
"manually_installed": true,
"releases": {
"9.9.9": {
"missing_metadata": true
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
9 changes: 6 additions & 3 deletions rpc/cc/arduino/cli/commands/v1/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions rpc/cc/arduino/cli/commands/v1/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit be1ecce

Please sign in to comment.