Commit dbdc3a5
fix(state): preserve 'version:' on b.yaml round-trip (--fix, oci:// tags) (#149)
## Summary
\`BinaryList.MarshalYAML\` emitted \`LocalBinary.Enforced\` as YAML
\`version:\` and ignored \`LocalBinary.Version\` entirely. Two visible
consequences:
1. \`b install --add oci://docker@cli\` produced \`oci://docker: {}\` in
\`b.yaml\` — the tag (\`cli\`) was loaded into \`Version\` (via
\`version:\`) and never written back out.
2. \`b install --fix jq@v1.7\` wrote \`version: v1.7\`. On reload only
\`Version\` was populated, so the \`--fix\` pin was silently lost; next
\`b update\` could move jq off the pinned version.
## Fix
Emit \`Version\` as \`version:\` and \`Enforced\` as \`enforced:\` in
\`BinaryList.MarshalYAML\`. The unmarshal path already maps them to
distinct YAML keys, so they now round-trip independently.
## Workflow
Split into two commits for clarity:
1. \`test(state): failing regression\` — adds 4 sub-tests for
\`MarshalYAML\` and a file-round-trip test, all currently failing.
2. \`fix(state): preserve 'version:' on b.yaml round-trip\` — implements
the fix; new tests pass; two existing tests updated from the old buggy
semantics to the correct ones.
## End-to-end reproduction
Before:
\`\`\`
$ b install --add oci://docker@cli:/usr/local/bin/docker
$ cat b.yaml
binaries:
oci://docker:/usr/local/bin/docker: {} # ← tag wiped
\`\`\`
After:
\`\`\`
binaries:
oci://docker:/usr/local/bin/docker:
version: cli
\`\`\`
## Test plan
- [x] \`TestBinaryListMarshalYAML_VersionRoundTrip\` (4 sub-tests:
version-only, enforced-only, both-set, oci-tag-as-version).
- [x] \`TestBinaryListMarshalYAML_VersionSurvivesFileRoundTrip\` — Load
→ Save → reload.
- [x] \`go test ./...\` — all 39 packages pass.
- [x] Manual e2e: \`b install --add
oci://docker@cli:/usr/local/bin/docker\` now writes \`version: cli\` to
b.yaml.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent a09a756 commit dbdc3a5
2 files changed
Lines changed: 137 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
349 | 356 | | |
350 | | - | |
| 357 | + | |
351 | 358 | | |
352 | 359 | | |
353 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| 321 | + | |
| 322 | + | |
320 | 323 | | |
321 | 324 | | |
322 | 325 | | |
| |||
333 | 336 | | |
334 | 337 | | |
335 | 338 | | |
336 | | - | |
| 339 | + | |
337 | 340 | | |
338 | 341 | | |
339 | 342 | | |
340 | 343 | | |
341 | | - | |
342 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
343 | 349 | | |
344 | 350 | | |
345 | 351 | | |
| |||
361 | 367 | | |
362 | 368 | | |
363 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
364 | 486 | | |
365 | 487 | | |
366 | 488 | | |
| |||
435 | 557 | | |
436 | 558 | | |
437 | 559 | | |
438 | | - | |
439 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
440 | 563 | | |
441 | 564 | | |
442 | 565 | | |
| |||
0 commit comments