Skip to content

scaffold generate --update strips trailing newlines (if any) from every merged file #2887

Closed

Description

Atmos version

1.225.0

Reproduction

# 1. Generate a scaffold template with --git so it has a merge base.
atmos scaffold generate <any-template> ./out --defaults --git

# 2. Confirm the file has a trailing newline.
xxd ./out/some-file | tail -1   # ends in ...0a (trailing \n)

# 3. Re-run --update with nothing changed on the template side (same source, same ref).
atmos scaffold generate <same-template> ./out --defaults --update

# 4. Compare.
xxd ./out/some-file | tail -1   # trailing \n is gone

This reproduces for every non-YAML file type merged through --update (Terraform, shell scripts, Markdown, arbitrary templates, etc.).

Expected

A file merged through --update, whether unchanged or genuinely updated by the template, should respect the original template's trailing newlines.--update should not unconditionally strip the final newline from every file it touches.

Impact

Every file atmos scaffold generate --update touches loses its trailing newline if there was any, unconditionally, regardless of file type or whether anything meaningful changed. This is the kind of change many linters, POSIX tools, and diff/patch tooling flag or warn on, and it produces a spurious one-line diff on every single managed file after every --update run.

Activity

  1. osterman commented on Aug 6, 2026

    @osterman
    Member

    Agree, it should respect the trailing new line settings of incoming files. Hopefully this one is easier to fix.

  2. jorrite commented on Aug 6, 2026

    @jorrite
    ContributorAuthor

    Bit of a rough fix, but if we want to keep the diff3 lib we rely on now, this works. Took a bit of time before landing on this 😅.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions