Skip to content

Commit fee697b

Browse files
authored
[per-OS Packages] omitempty for version in expanded Package json representation (#1440)
## Summary Discussing with @Lagoja, we felt that we can omit the version string if its empty ## How was it tested? `devbox add github:F1bonacc1/process-compose --exclude-platform x86_64-darwin`: BEFORE: ``` { "packages": { "github:F1bonacc1/process-compose/v0.40.2": { "version": "", "excluded_platforms": [ "x86_64-darwin" ] } }, ... } ``` AFTER: ``` { "packages": { "github:F1bonacc1/process-compose/v0.40.2": { "excluded_platforms": [ "x86_64-darwin" ] } }, ... } ```
1 parent 8e496f6 commit fee697b

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

internal/devconfig/packages.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ const (
200200
)
201201

202202
type Package struct {
203-
kind packageKind
204-
name string
205-
// deliberately not adding omitempty
206-
Version string `json:"version"`
203+
kind packageKind
204+
name string
205+
Version string `json:"version,omitempty"`
207206

208207
Platforms []string `json:"platforms,omitempty"`
209208
ExcludedPlatforms []string `json:"excluded_platforms,omitempty"`
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Testscript for exercising adding packages using a flake ref
2+
3+
exec devbox install
4+
5+
exec devbox add github:F1bonacc1/process-compose/v0.40.2 --exclude-platform x86_64-darwin
6+
json.superset devbox.json expected_devbox1.json
7+
8+
-- devbox.json --
9+
{
10+
"packages": [
11+
"hello",
12+
"cowsay@latest"
13+
]
14+
}
15+
16+
-- expected_devbox1.json --
17+
{
18+
"packages": {
19+
"hello": "",
20+
"cowsay": "latest",
21+
"github:F1bonacc1/process-compose/v0.40.2": {
22+
"excluded_platforms": ["x86_64-darwin"]
23+
}
24+
}
25+
}
26+

0 commit comments

Comments
 (0)