Repository navigation
Conversation
select_lines() was stripping all comment-only lines from YAML files,
but this incorrectly removed # comment lines that are part of
multi-line string values in block scalars (| or >).
For example, in:
condarc: |
# This config file should be located in ...
allow_other_channels: yes
the # comment line was being stripped, breaking the string value.
Fix: track block scalar context by indentation level. When inside
a block scalar, preserve all lines verbatim (including # comments).
Exit block scalar context when we encounter a non-empty line at
the same or lower indentation level as the block key.
Fixes conda#1240
Tests verify: - Lines that look like comments inside block scalars (| or >) are preserved - After a block scalar ends, normal comment skipping resumes - Both literal (|) and folded (>) block scalars handle # lines correctly news/1371 documents the bug fix for block scalar comment handling. Refs: conda#1371
Marcoesters suggested not filtering out comment-only lines since they
don't hurt anything. Removed the stripped.startswith('#') continue
filter so comments pass through to the selector match and are preserved.
Contributor
|
We require contributors to sign our Contributor License Agreement and we don't have one on file for @Jah-yee. In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature, merge the PR (conda/infrastructure#1481), and ping the bot to refresh the PR. |
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.
Fixes #1240
select_lines() was stripping comment-only lines from YAML block scalars.
Fix: track block scalar context to preserve # comments inside | or > blocks.