Skip to content

Commit 20bf771

Browse files
committed
Add core ID in outdated command output (#1406)
1 parent b9b7a87 commit 20bf771

File tree

7 files changed

+45
-14
lines changed

7 files changed

+45
-14
lines changed

cli/outdated/outdated.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ func runOutdatedCommand(cmd *cobra.Command, args []string) {
5959

6060
// Prints outdated cores
6161
tab := table.New()
62-
tab.SetHeader(tr("Core name"), tr("Installed version"), tr("New version"))
62+
tab.SetHeader(tr("ID"), tr("Installed version"), tr("New version"), tr("Name"))
6363
if len(outdatedResp.OutdatedPlatforms) > 0 {
6464
for _, p := range outdatedResp.OutdatedPlatforms {
65-
tab.AddRow(p.Name, p.Installed, p.Latest)
65+
tab.AddRow(p.Id, p.Installed, p.Latest, p.Name)
6666
}
6767
feedback.Print(tab.Render())
6868
}

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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ msgstr "Connected"
378378
msgid "Core"
379379
msgstr "Core"
380380

381-
#: cli/outdated/outdated.go:62
382381
#: cli/update/update.go:99
383382
msgid "Core name"
384383
msgstr "Core name"
@@ -914,6 +913,7 @@ msgstr "Global variables use {0} bytes of dynamic memory."
914913

915914
#: cli/core/list.go:84
916915
#: cli/core/search.go:114
916+
#: cli/outdated/outdated.go:62
917917
msgid "ID"
918918
msgstr "ID"
919919

@@ -1192,6 +1192,7 @@ msgstr "Multiple libraries were found for \"{0}\""
11921192
#: cli/core/list.go:84
11931193
#: cli/core/search.go:114
11941194
#: cli/lib/list.go:125
1195+
#: cli/outdated/outdated.go:62
11951196
msgid "Name"
11961197
msgstr "Name"
11971198

@@ -2128,6 +2129,10 @@ msgstr "can't find dependencies for platform %[1]s: %[2]w"
21282129
msgid "can't find latest release of %s"
21292130
msgstr "can't find latest release of %s"
21302131

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+
21312136
#: arduino/sketch/sketch.go:101
21322137
msgid "can't find main Sketch file in %s"
21332138
msgstr "can't find main Sketch file in %s"
@@ -2629,7 +2634,7 @@ msgstr "invalid hash '%[1]s': %[2]s"
26292634
#: commands/compile/compile.go:93
26302635
#: commands/core/download.go:36
26312636
#: commands/core/install.go:35
2632-
#: commands/core/list.go:38
2637+
#: commands/core/list.go:39
26332638
#: commands/core/search.go:40
26342639
#: commands/core/uninstall.go:33
26352640
#: commands/core/upgrade.go:40
@@ -3309,7 +3314,7 @@ msgstr "unable to create a folder to save the sketch files"
33093314
msgid "unable to create the folder containing the item"
33103315
msgstr "unable to create the folder containing the item"
33113316

3312-
#: commands/core/list.go:33
3317+
#: commands/core/list.go:34
33133318
msgid "unable to find an instance with ID: %d"
33143319
msgstr "unable to find an instance with ID: %d"
33153320

i18n/rice-box.go

Lines changed: 4 additions & 4 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:[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

test/test_outdated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def test_outdated(run_command):
3333
result = run_command("outdated")
3434
assert result.ok
3535
lines = [l.strip() for l in result.stdout.splitlines()]
36-
assert lines[1].startswith("Arduino AVR Boards")
37-
assert lines[4].startswith("USBHost")
36+
assert "Arduino AVR Boards" in lines[1]
37+
assert "USBHost" in lines[4]
3838

3939

4040
def test_outdated_using_library_with_invalid_version(run_command, data_dir):

test/test_upgrade.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def test_upgrade(run_command):
3333
result = run_command("outdated")
3434
assert result.ok
3535
lines = result.stdout.splitlines()
36-
assert lines[1].startswith("Arduino AVR Boards")
37-
assert lines[4].startswith("USBHost")
36+
assert "Arduino AVR Boards" in lines[1]
37+
assert "USBHost" in lines[4]
3838

3939
result = run_command("upgrade")
4040
assert result.ok

0 commit comments

Comments
 (0)