Realign comment indentation and add --no-blank-line-before-processor#120
Open
jgstew wants to merge 1 commit into
Open
Realign comment indentation and add --no-blank-line-before-processor#120jgstew wants to merge 1 commit into
jgstew wants to merge 1 commit into
Conversation
ruamel.yaml round-trips comments at their original absolute column, so a comment does not move when the surrounding structural indentation changes (most visibly on Process list items, re-emitted with the dash at column 0). Add a post-dump pass that reindents comment-only lines to match the content they precede, and add an opt-out flag for the blank line before processors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
I am using this pre-commit hook to add blank line before - Processor: but in way where it adds the blank line above a comment that is at the same indent as - Processor but this hook does not do that properly, thus the disable flag. For example: ends up as: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE: this was done with Claude Code
Problem
format-autopkg-yaml-recipesuses ruamel.yaml round-trip mode, which re-emits each comment at its original absolute column. When the formatter changes structural indentation — most visibly onProcess:lists, which it re-emits with the dash at column 0 (sequence=2, offset=0) whereas my recipes are commonly authored with 4-space list indentation — the surrounding keys move but comments stay put and drift out of alignment:Changes
_realign_comments: a post-dump text pass that reindents each comment-only line to the indentation of the next content line (falling back to the previous content line for trailing comments at the end of a block). Inlinekey: value # ...comments are untouched.--no-blank-line-before-processor: optional flag that drops- Processor:from the blank-line insertion. Useful when a separate hook manages spacing between processors; it also keeps a comment tight against the processor it documents. Default behavior is unchanged.Tests
Added coverage for comment realignment on a reindented
Processlist, for the new flag keeping comments tight, and for the default still inserting a blank line before processors. Full suite passes (228 tests) and output is idempotent.