Skip to content

Commit 50d74a4

Browse files
rename 'incompatible' field to 'compatible'
1 parent 0d44f44 commit 50d74a4

File tree

10 files changed

+132
-129
lines changed

10 files changed

+132
-129
lines changed

Diff for: arduino/cores/cores.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type PlatformRelease struct {
7575
PluggableDiscoveryAware bool `json:"-"` // true if the Platform supports pluggable discovery (no compatibility layer required)
7676
Monitors map[string]*MonitorDependency `json:"-"`
7777
MonitorsDevRecipes map[string]string `json:"-"`
78-
Incompatible bool `json:"-"` // true if at least one ToolDependencies is not available for the current OS/ARCH.
78+
Compatible bool `json:"-"` // true if at all ToolDependencies are available for the current OS/ARCH.
7979
}
8080

8181
// BoardManifest contains information about a board. These metadata are usually
@@ -238,7 +238,7 @@ func (platform *Platform) GetLatestCompatibleRelease() *PlatformRelease {
238238
}
239239
maximum := &PlatformRelease{Version: &semver.Version{}}
240240
for _, release := range platform.Releases {
241-
if release.Incompatible {
241+
if !release.IsCompatible() {
242242
continue
243243
}
244244
if release.Version.GreaterThan(maximum.Version) {
@@ -278,7 +278,7 @@ func (platform *Platform) GetAllReleasesVersions() []*semver.Version {
278278
func (platform *Platform) GetAllCompatibleReleasesVersions() []*semver.Version {
279279
versions := []*semver.Version{}
280280
for _, release := range platform.Releases {
281-
if release.Incompatible {
281+
if !release.IsCompatible() {
282282
continue
283283
}
284284
versions = append(versions, release.Version)
@@ -477,8 +477,8 @@ func (release *PlatformRelease) HasMetadata() bool {
477477
return installedJSONPath.Exist()
478478
}
479479

480-
// IsIncompatible returns true if the PlatformRelease contains tool
481-
// dependencies that are not available in the current OS/ARCH.
482-
func (release *PlatformRelease) IsIncompatible() bool {
483-
return release.Incompatible
480+
// IsCompatible returns true if all the tools dependencies of a PlatformRelease
481+
// are available in the current OS/ARCH.
482+
func (release *PlatformRelease) IsCompatible() bool {
483+
return release.Compatible
484484
}

Diff for: arduino/cores/packagemanager/package_manager.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -121,37 +121,37 @@ func (pmb *Builder) Build() *PackageManager {
121121
}
122122
}
123123

124-
func (pmb *Builder) calculateIncompatibleVersions() {
125-
// calculates Incompatible PlatformRelease
124+
// calculate Compatible PlatformRelease
125+
func (pmb *Builder) calculateCompatibleReleases() {
126126
for _, op := range pmb.packages {
127127
for _, p := range op.Platforms {
128128
for _, pr := range p.Releases {
129-
platformHasIncompatibleTools := func() bool {
129+
platformHasAllCompatibleTools := func() bool {
130130
for _, td := range pr.ToolDependencies {
131131
if td == nil {
132-
return true
132+
return false
133133
}
134134

135135
_, ok := pmb.packages[td.ToolPackager]
136136
if !ok {
137-
return true
137+
return false
138138
}
139139
tool := pmb.packages[td.ToolPackager].Tools[td.ToolName]
140140
if tool == nil {
141-
return true
141+
return false
142142
}
143143
tr := tool.Releases[td.ToolVersion.NormalizedString()]
144144
if tr == nil {
145-
return true
145+
return false
146146
}
147147

148148
if tr.GetCompatibleFlavour() == nil {
149-
return true
149+
return false
150150
}
151151
}
152-
return false
152+
return true
153153
}
154-
pr.Incompatible = platformHasIncompatibleTools()
154+
pr.Compatible = platformHasAllCompatibleTools()
155155
}
156156
}
157157
}
@@ -164,7 +164,7 @@ func (pmb *Builder) calculateIncompatibleVersions() {
164164
func (pm *PackageManager) NewBuilder() (builder *Builder, commit func()) {
165165
pmb := NewBuilder(pm.IndexDir, pm.PackagesDir, pm.DownloadDir, pm.tempDir, pm.userAgent)
166166
return pmb, func() {
167-
pmb.calculateIncompatibleVersions()
167+
pmb.calculateCompatibleReleases()
168168
pmb.BuildIntoExistingPackageManager(pm)
169169
}
170170
}

Diff for: arduino/cores/packagemanager/package_manager_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ func TestFindToolsRequiredFromPlatformRelease(t *testing.T) {
744744
func TestFindPlatformReleaseDependencies(t *testing.T) {
745745
pmb := NewBuilder(nil, nil, nil, nil, "test")
746746
pmb.LoadPackageIndexFromFile(paths.New("testdata", "package_tooltest_index.json"))
747+
pmb.calculateCompatibleReleases()
747748
pm := pmb.Build()
748749
pme, release := pm.NewExplorer()
749750
defer release()

Diff for: commands/core.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.PlatformR
7474
MissingMetadata: missingMetadata,
7575
Type: []string{platformRelease.Category},
7676
Deprecated: platformRelease.Deprecated,
77-
Incompatible: platformRelease.IsIncompatible(),
77+
Compatible: platformRelease.IsCompatible(),
7878
}
7979
}

Diff for: commands/core/search_test.go

+67-67
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ func TestPlatformSearch(t *testing.T) {
6161
},
6262
Releases: map[string]*rpc.PlatformRelease{
6363
"1.0.5": {
64-
Name: "RK002",
65-
Type: []string{"Contributed"},
66-
Installed: false,
67-
Version: "1.0.5",
68-
Boards: []*rpc.Board{{Name: "RK002"}},
69-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
70-
Incompatible: true,
64+
Name: "RK002",
65+
Type: []string{"Contributed"},
66+
Installed: false,
67+
Version: "1.0.5",
68+
Boards: []*rpc.Board{{Name: "RK002"}},
69+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
70+
Compatible: false,
7171
},
7272
"1.0.6": {
73-
Name: "RK002",
74-
Type: []string{"Contributed"},
75-
Installed: false,
76-
Version: "1.0.6",
77-
Boards: []*rpc.Board{{Name: "RK002"}},
78-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
79-
Incompatible: true,
73+
Name: "RK002",
74+
Type: []string{"Contributed"},
75+
Installed: false,
76+
Version: "1.0.6",
77+
Boards: []*rpc.Board{{Name: "RK002"}},
78+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
79+
Compatible: false,
8080
},
8181
},
8282
InstalledVersion: "",
@@ -103,13 +103,13 @@ func TestPlatformSearch(t *testing.T) {
103103
},
104104
Releases: map[string]*rpc.PlatformRelease{
105105
"1.0.6": {
106-
Name: "RK002",
107-
Type: []string{"Contributed"},
108-
Installed: false,
109-
Version: "1.0.6",
110-
Boards: []*rpc.Board{{Name: "RK002"}},
111-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
112-
Incompatible: true,
106+
Name: "RK002",
107+
Type: []string{"Contributed"},
108+
Installed: false,
109+
Version: "1.0.6",
110+
Boards: []*rpc.Board{{Name: "RK002"}},
111+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
112+
Compatible: false,
113113
},
114114
},
115115
InstalledVersion: "",
@@ -136,22 +136,22 @@ func TestPlatformSearch(t *testing.T) {
136136
},
137137
Releases: map[string]*rpc.PlatformRelease{
138138
"1.0.5": {
139-
Name: "RK002",
140-
Type: []string{"Contributed"},
141-
Installed: false,
142-
Version: "1.0.5",
143-
Boards: []*rpc.Board{{Name: "RK002"}},
144-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
145-
Incompatible: true,
139+
Name: "RK002",
140+
Type: []string{"Contributed"},
141+
Installed: false,
142+
Version: "1.0.5",
143+
Boards: []*rpc.Board{{Name: "RK002"}},
144+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
145+
Compatible: false,
146146
},
147147
"1.0.6": {
148-
Name: "RK002",
149-
Type: []string{"Contributed"},
150-
Installed: false,
151-
Version: "1.0.6",
152-
Boards: []*rpc.Board{{Name: "RK002"}},
153-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
154-
Incompatible: true,
148+
Name: "RK002",
149+
Type: []string{"Contributed"},
150+
Installed: false,
151+
Version: "1.0.6",
152+
Boards: []*rpc.Board{{Name: "RK002"}},
153+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
154+
Compatible: false,
155155
},
156156
},
157157
InstalledVersion: "",
@@ -178,22 +178,22 @@ func TestPlatformSearch(t *testing.T) {
178178
},
179179
Releases: map[string]*rpc.PlatformRelease{
180180
"1.0.5": {
181-
Name: "RK002",
182-
Type: []string{"Contributed"},
183-
Installed: false,
184-
Version: "1.0.5",
185-
Boards: []*rpc.Board{{Name: "RK002"}},
186-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
187-
Incompatible: true,
181+
Name: "RK002",
182+
Type: []string{"Contributed"},
183+
Installed: false,
184+
Version: "1.0.5",
185+
Boards: []*rpc.Board{{Name: "RK002"}},
186+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
187+
Compatible: false,
188188
},
189189
"1.0.6": {
190-
Name: "RK002",
191-
Type: []string{"Contributed"},
192-
Installed: false,
193-
Version: "1.0.6",
194-
Boards: []*rpc.Board{{Name: "RK002"}},
195-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
196-
Incompatible: true,
190+
Name: "RK002",
191+
Type: []string{"Contributed"},
192+
Installed: false,
193+
Version: "1.0.6",
194+
Boards: []*rpc.Board{{Name: "RK002"}},
195+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
196+
Compatible: false,
197197
},
198198
},
199199
InstalledVersion: "",
@@ -220,22 +220,22 @@ func TestPlatformSearch(t *testing.T) {
220220
},
221221
Releases: map[string]*rpc.PlatformRelease{
222222
"1.0.5": {
223-
Name: "RK002",
224-
Type: []string{"Contributed"},
225-
Installed: false,
226-
Version: "1.0.5",
227-
Boards: []*rpc.Board{{Name: "RK002"}},
228-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
229-
Incompatible: true,
223+
Name: "RK002",
224+
Type: []string{"Contributed"},
225+
Installed: false,
226+
Version: "1.0.5",
227+
Boards: []*rpc.Board{{Name: "RK002"}},
228+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
229+
Compatible: false,
230230
},
231231
"1.0.6": {
232-
Name: "RK002",
233-
Type: []string{"Contributed"},
234-
Installed: false,
235-
Version: "1.0.6",
236-
Boards: []*rpc.Board{{Name: "RK002"}},
237-
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
238-
Incompatible: true,
232+
Name: "RK002",
233+
Type: []string{"Contributed"},
234+
Installed: false,
235+
Version: "1.0.6",
236+
Boards: []*rpc.Board{{Name: "RK002"}},
237+
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
238+
Compatible: false,
239239
},
240240
},
241241
InstalledVersion: "",
@@ -294,8 +294,8 @@ func TestPlatformSearch(t *testing.T) {
294294
{Name: "Arduino Industrial 101"},
295295
{Name: "Linino One"},
296296
},
297-
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
298-
Incompatible: true,
297+
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
298+
Compatible: false,
299299
},
300300
},
301301
InstalledVersion: "",
@@ -354,8 +354,8 @@ func TestPlatformSearch(t *testing.T) {
354354
{Name: "Arduino Industrial 101"},
355355
{Name: "Linino One"},
356356
},
357-
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
358-
Incompatible: true,
357+
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
358+
Compatible: false,
359359
},
360360
},
361361
InstalledVersion: "",

Diff for: docs/UPGRADING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Here you can find a list of migration guides to handle breaking changes between
66

77
### The gRPC `cc.arduino.cli.commands.v1.PlatformRelease` has been changed.
88

9-
We've added a new field called `incompatible`. This field indicates if the current platform release is installable or
10-
not. It may happen that a platform doesn't have a dependency available for an OS, in such cases, if we try to install
11-
the platform it will fail. The new field can be used to know upfront if a specific release is installable.
9+
We've added a new field called `compatible`. This field indicates if the current platform release is installable or not.
10+
It may happen that a platform doesn't have a dependency available for an OS, in such cases, if we try to install the
11+
platform it will fail. The new field can be used to know upfront if a specific release is installable.
1212

1313
### The gRPC `cc.arduino.cli.commands.v1.PlatformSummary` has been changed.
1414

Diff for: internal/cli/feedback/result/rpc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func NewPlatformRelease(in *rpc.PlatformRelease) *PlatformRelease {
109109
Help: help,
110110
MissingMetadata: in.MissingMetadata,
111111
Deprecated: in.Deprecated,
112-
Incompatible: in.Incompatible,
112+
Compatible: in.Compatible,
113113
}
114114
return res
115115
}
@@ -124,7 +124,7 @@ type PlatformRelease struct {
124124
Help *HelpResource `json:"help,omitempty"`
125125
MissingMetadata bool `json:"missing_metadata,omitempty"`
126126
Deprecated bool `json:"deprecated,omitempty"`
127-
Incompatible bool `json:"incompatible,omitempty"`
127+
Compatible bool `json:"compatible"`
128128
}
129129

130130
// Board maps a rpc.Board

Diff for: internal/integrationtest/core/core_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1182,19 +1182,19 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
11821182
stdout, _, err = cli.Run("core", "search", "--all", "--format", "json", additionalURLs)
11831183
require.NoError(t, err)
11841184
requirejson.Query(t, stdout,
1185-
`[.[] | select(.id == "foo_vendor:avr") | .releases | map(.) | .[] | {version: .version, incompatible: .incompatible}] | sort_by(.version)`,
1185+
`[.[] | select(.id == "foo_vendor:avr") | .releases | map(.) | .[] | {version: .version, compatible: .compatible}] | sort_by(.version)`,
11861186
`[
1187-
{"incompatible":null,"version":"1.0.0"},
1188-
{"incompatible":null,"version":"1.0.1"},
1189-
{"incompatible":true,"version":"1.0.2"}
1187+
{"compatible":true,"version":"1.0.0"},
1188+
{"compatible":true,"version":"1.0.1"},
1189+
{"compatible":false,"version":"1.0.2"}
11901190
]`,
11911191
)
11921192

11931193
// Core search shows latest compatible version even if incompatible
11941194
stdout, _, err = cli.Run("core", "search", "--format", "json", additionalURLs)
11951195
require.NoError(t, err)
11961196
requirejson.Query(t, stdout, `.[] | select(.id == "foo_vendor:avr") | .latest_version`, `"1.0.2"`)
1197-
requirejson.Query(t, stdout, `.[] | select(.id == "incompatible_vendor:avr") | .releases[.latest_version].incompatible`, `true`)
1197+
requirejson.Query(t, stdout, `.[] | select(.id == "incompatible_vendor:avr") | .releases[.latest_version].compatible`, `false`)
11981198

11991199
// In text mode, core search doesn't show any version if no compatible one are present
12001200
stdout, _, err = cli.Run("core", "search", additionalURLs)

0 commit comments

Comments
 (0)