Skip to content

Commit 7072e74

Browse files
committed
Add core ID in outdated command output (#1406)
1 parent 1c3a2df commit 7072e74

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

Diff for: commands/core/list.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package core
1717

1818
import (
19+
"fmt"
1920
"sort"
2021
"strings"
2122

@@ -58,14 +59,20 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
5859
}
5960

6061
if platformRelease != nil {
62+
latest := platform.GetLatestRelease()
63+
if latest == nil {
64+
return nil, fmt.Errorf(tr("can't find latest release of core %s", platform))
65+
}
66+
6167
if req.UpdatableOnly {
62-
if latest := platform.GetLatestRelease(); latest == nil || latest == platformRelease {
68+
if latest == platformRelease {
6369
continue
6470
}
6571
}
6672

6773
rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)
6874
rpcPlatform.Installed = platformRelease.Version.String()
75+
rpcPlatform.Latest = latest.Version.String()
6976
res = append(res, rpcPlatform)
7077
}
7178
}

Diff for: i18n/data/en.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -2129,6 +2129,10 @@ msgstr "can't find dependencies for platform %[1]s: %[2]w"
21292129
msgid "can't find latest release of %s"
21302130
msgstr "can't find latest release of %s"
21312131

2132+
#: commands/core/list.go:64
2133+
msgid "can't find latest release of core %s"
2134+
msgstr "can't find latest release of core %s"
2135+
21322136
#: arduino/sketch/sketch.go:101
21332137
msgid "can't find main Sketch file in %s"
21342138
msgstr "can't find main Sketch file in %s"
@@ -2630,7 +2634,7 @@ msgstr "invalid hash '%[1]s': %[2]s"
26302634
#: commands/compile/compile.go:93
26312635
#: commands/core/download.go:36
26322636
#: commands/core/install.go:35
2633-
#: commands/core/list.go:38
2637+
#: commands/core/list.go:39
26342638
#: commands/core/search.go:40
26352639
#: commands/core/uninstall.go:33
26362640
#: commands/core/upgrade.go:40
@@ -3310,7 +3314,7 @@ msgstr "unable to create a folder to save the sketch files"
33103314
msgid "unable to create the folder containing the item"
33113315
msgstr "unable to create the folder containing the item"
33123316

3313-
#: commands/core/list.go:33
3317+
#: commands/core/list.go:34
33143318
msgid "unable to find an instance with ID: %d"
33153319
msgstr "unable to find an instance with ID: %d"
33163320

Diff for: i18n/rice-box.go

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

Diff for: test/test_core.py

+19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import hashlib
2424
from git import Repo
2525
from pathlib import Path
26+
import semver
2627

2728

2829
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)
753754
+ "skipping loading of boards arduino-beta-dev:platform_with_missing_custom_board_options:nessuno: "
754755
+ "malformed custom board options"
755756
) in res.stderr
757+
758+
759+
def test_core_list_outdated_core(run_command):
760+
assert run_command("update")
761+
762+
# Install an old core version
763+
assert run_command("core install arduino:[email protected]")
764+
765+
res = run_command("core list --format json")
766+
767+
data = json.loads(res.stdout)
768+
assert len(data) == 1
769+
samd_core = data[0]
770+
assert samd_core["installed"] == "1.8.6"
771+
installed_version = semver.parse_version_info(samd_core["installed"])
772+
latest_version = semver.parse_version_info(samd_core["latest"])
773+
# Installed version must be older than latest
774+
assert installed_version.compare(latest_version) == -1

0 commit comments

Comments
 (0)