Unverified Commit 372b881f authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

Fix core list command not returning latest available version (#1409)

parent 01c07b61
......@@ -16,6 +16,7 @@
package core
import (
"fmt"
"sort"
"strings"
......@@ -58,14 +59,20 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
}
if platformRelease != nil {
latest := platform.GetLatestRelease()
if latest == nil {
return nil, fmt.Errorf(tr("can't find latest release of core %s", platform))
}
if req.UpdatableOnly {
if latest := platform.GetLatestRelease(); latest == nil || latest == platformRelease {
if latest == platformRelease {
continue
}
}
rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)
rpcPlatform.Installed = platformRelease.Version.String()
rpcPlatform.Latest = latest.Version.String()
res = append(res, rpcPlatform)
}
}
......
......@@ -2129,6 +2129,10 @@ msgstr "can't find dependencies for platform %[1]s: %[2]w"
msgid "can't find latest release of %s"
msgstr "can't find latest release of %s"
#: commands/core/list.go:64
msgid "can't find latest release of core %s"
msgstr "can't find latest release of core %s"
#: arduino/sketch/sketch.go:101
msgid "can't find main Sketch file in %s"
msgstr "can't find main Sketch file in %s"
......@@ -2630,7 +2634,7 @@ msgstr "invalid hash '%[1]s': %[2]s"
#: commands/compile/compile.go:93
#: commands/core/download.go:36
#: commands/core/install.go:35
#: commands/core/list.go:38
#: commands/core/list.go:39
#: commands/core/search.go:40
#: commands/core/uninstall.go:33
#: commands/core/upgrade.go:40
......@@ -3306,7 +3310,7 @@ msgstr "unable to create a folder to save the sketch files"
msgid "unable to create the folder containing the item"
msgstr "unable to create the folder containing the item"
#: commands/core/list.go:33
#: commands/core/list.go:34
msgid "unable to find an instance with ID: %d"
msgstr "unable to find an instance with ID: %d"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -23,6 +23,7 @@ import tempfile
import hashlib
from git import Repo
from pathlib import Path
import semver
def test_core_search(run_command, httpserver):
......@@ -753,3 +754,21 @@ def test_core_with_missing_custom_board_options_is_loaded(run_command, data_dir)
+ "skipping loading of boards arduino-beta-dev:platform_with_missing_custom_board_options:nessuno: "
+ "malformed custom board options"
) in res.stderr
def test_core_list_outdated_core(run_command):
assert run_command("update")
# Install an old core version
assert run_command("core install arduino:samd@1.8.6")
res = run_command("core list --format json")
data = json.loads(res.stdout)
assert len(data) == 1
samd_core = data[0]
assert samd_core["installed"] == "1.8.6"
installed_version = semver.parse_version_info(samd_core["installed"])
latest_version = semver.parse_version_info(samd_core["latest"])
# Installed version must be older than latest
assert installed_version.compare(latest_version) == -1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment