Skip to content

fix: preserve trailing blank lines when fqcn auto-fix renames a key#5027

Open
bishalOps wants to merge 1 commit intoansible:mainfrom
bishalOps:fix/fqcn-preserve-blanks-on-rename
Open

fix: preserve trailing blank lines when fqcn auto-fix renames a key#5027
bishalOps wants to merge 1 commit intoansible:mainfrom
bishalOps:fix/fqcn-preserve-blanks-on-rename

Conversation

@bishalOps
Copy link
Copy Markdown

ansible-lint --fix for fqcn[*] was dropping blank lines between tasks, and also trailing comments, when the renamed key was the last key in a task mapping (#4543). In ruamel.yaml, blank-line and trailing-comment metadata are stored in ca.items keyed by the original mapping key. The transform removes and reinserts the renamed key, but does not rebind ca.items, so the metadata is left orphaned under the old key name and the YAML emitter drops it. This fix migrates ca.items[old_key] to ca.items[new_key] after renaming so the formatting metadata is preserved during emission

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

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant