Commit ff07003
fix(dockerfile): unbound ARG shadowing ENV, and dockerfile:1 build-context support
Ported reference/src/test/dockerfileUtils.test.ts as an oracle (38 cases across
ensureDockerfileHasFinalStageName / findBaseImage / findUserStatement /
supportsBuildContexts). Two cases failed — both real bugs the oracle caught:
- findUserStatement: an unbound `ARG X` (no value, no --build-arg) after an
`ENV X=...` returned "" instead of the ENV value, because the ARG branch
early-returned "" and shadowed the earlier ENV. TS treats an unbound ARG's
value as undefined (its match predicate excludes it), so the search must fall
through to the ENV. Skip an unbound, un-overridden ARG and keep scanning.
- supportsBuildContexts: `# syntax=docker/dockerfile:1` reported false. TS uses
semver.intersects(version, ">=1.4"), treating the partial tag "1" as the range
1.x (floating latest, which supports build contexts) — not the exact 1.0.0
that a plain semver parse produced. Replicate the range-intersection semantics
(verified against the full 22-row version matrix from the reference test).
The oracle's expected values are transcribed verbatim from the TS; no expectation
was adjusted to pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 4490760 commit ff07003
2 files changed
Lines changed: 622 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | | - | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
261 | 260 | | |
262 | 261 | | |
263 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
264 | 269 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
272 | 288 | | |
273 | | - | |
274 | 289 | | |
275 | 290 | | |
276 | 291 | | |
| |||
368 | 383 | | |
369 | 384 | | |
370 | 385 | | |
371 | | - | |
372 | 386 | | |
373 | | - | |
| 387 | + | |
374 | 388 | | |
375 | | - | |
376 | | - | |
| 389 | + | |
| 390 | + | |
377 | 391 | | |
378 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
379 | 397 | | |
380 | 398 | | |
381 | 399 | | |
| |||
0 commit comments