Skip to content

Lockfile trailing newline fix and normalization for frozen lockfile comparison#1196

Merged
chrmarti merged 9 commits intodevcontainers:mainfrom
brooke-hamilton:newline-fix
Apr 17, 2026
Merged

Lockfile trailing newline fix and normalization for frozen lockfile comparison#1196
chrmarti merged 9 commits intodevcontainers:mainfrom
brooke-hamilton:newline-fix

Conversation

@brooke-hamilton
Copy link
Copy Markdown
Contributor

Summary

Fixes lockfile handling to ensure trailing newlines and normalize formatting when comparing lockfiles in frozen mode.

Fixes #1008

Changes

  • Trailing newline: Lockfiles now always end with a trailing newline per POSIX convention
  • Frozen lockfile comparison: Normalizes existing lockfile content through JSON.parse → JSON.stringify before comparing, so cosmetic formatting differences (indentation, trailing whitespace, missing newline) don't cause false mismatches in frozen mode
  • Added comments: Explanatory comments for the POSIX newline convention and normalization logic

Modified Files

  • src/spec-configuration/lockfile.ts - Core lockfile logic with newline and normalization fixes
  • src/test/container-features/lockfile.test.ts - New tests for:
    • Lockfile ends with trailing newline
    • Frozen lockfile matches despite formatting differences
    • Frozen lockfile fails when lockfile does not exist
    • Corrupt lockfile causes build error
    • No lockfile flags with no existing lockfile is a no-op
  • Test fixture updates to include trailing newlines in expected lockfiles
  • New test fixture lockfile-frozen-no-lockfile for missing lockfile test

Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
@brooke-hamilton brooke-hamilton requested a review from a team as a code owner April 9, 2026 01:31
Comment thread src/test/tsconfig.json Outdated
Comment thread .vscode/settings.json
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left a question.

Comment thread src/spec-configuration/lockfile.ts Outdated
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
@chrmarti chrmarti merged commit 539c04c into devcontainers:main Apr 17, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add newline at EOF to devcontainer-lock.json

3 participants