Skip to content

Commit 372b881

Browse files
authored
Fix core list command not returning latest available version (arduino#1409)
1 parent 01c07b6 commit 372b881

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

commands/core/list.go

Lines changed: 8 additions & 1 deletion
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
}

i18n/data/en.po

Lines changed: 6 additions & 2 deletions
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
@@ -3306,7 +3310,7 @@ msgstr "unable to create a folder to save the sketch files"
33063310
msgid "unable to create the folder containing the item"
33073311
msgstr "unable to create the folder containing the item"
33083312

3309-
#: commands/core/list.go:33
3313+
#: commands/core/list.go:34
33103314
msgid "unable to find an instance with ID: %d"
33113315
msgstr "unable to find an instance with ID: %d"
33123316

i18n/rice-box.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test_core.py

Lines changed: 19 additions & 0 deletions
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:samd@1.8.6")
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy