Repository navigation
fix(connect): keep comments after the connect-config extension on clean - #448
Open
avocado-connect[bot] wants to merge 1 commit into
Open
avocado-connect[bot] wants to merge 1 commit into
avocado-connect[bot] wants to merge 1 commit into
Conversation
remove_extension_definition counted every blank and comment line after the extension as part of its block, at any indent, so connect clean deleted a comment above the next extension, or a column-0 section header after the last one. The block now ends at its last real child line. Comments indented deeper than the key right after it still go with the block; anything else stays with the next key. When the extension is the first one, no blank line is left under extensions:. Fixes #447
There was a problem hiding this comment.
🔵 Needs a closer look
Human judgment is needed to decide whether to waive Issue #447’s required Jetson before/after validation and Rubicon hardware status check, since the PR reports only host validation for this text-only fix.
No open issues 🎉
What changed in this PR
Fixes #447 by narrowing the extension block removed by avocado connect clean, preserving comments and spacing that belong to the following configuration.
Changes:
- Preserves comments after the connect-config extension while removing its indented trailing comments and avoiding a blank line directly under
extensions:. - Adds three regression tests covering next-extension comments, trailing section headers, and first-extension spacing.
- Documents the fix in the changelog.
| File | Description |
|---|---|
src/utils/config_edit.rs |
Adjusts extension-removal boundaries and adds regression tests, including YAML validity checks. |
CHANGELOG.md |
Adds an unreleased entry describing comment preservation during connect clean. |
Review effort: Balanced
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.
Issue
Fixes #447: connect clean deletes comments after the avocado-ext-connect-config block
avocado connect cleanremoves theavocado-ext-connect-configextension fromavocado.yaml. The report says it also deletes blank lines and comments that follow that block, such as a comment above the next extension, or a column-0 section header when connect-config is the last extension. Expected: only the block and its runtime list entry go away.The bug is in a pure text edit of
avocado.yaml, so it was reproduced and fixed with host unit tests and a run of the built binary. No board run: nothing on the device changes, and the edited file is byte-identical apart from the removed lines.Root cause
remove_extension_definition(src/utils/config_edit.rs) found the end of the extension block by extendingblock_endover every blank or comment line, at any indent, until it hit a real line at the key's indent. Everything up to the next key was deleted with the block.Fix
Same rule as #443 uses for top-level blocks:
extensions:.The other removal helpers were checked:
remove_runtime_extension_entryandremove_packages_from_yamldrop only matching lines inside their range, so comments survive there.remove_connect_fields_in_yamlhas the same loop and is fixed by #443.Reproduction
Three new unit tests on the pure functions: a comment above the next extension stays; a column-0
##header after the last extension stays (and an indented trailing comment inside the block goes with it); removing the first extension leaves no blank line underextensions:. The first two also parse the result as YAML.Before (main):
After:
avocado connect clean(built from this branch) on the issue's example file:app: packages: hello: '*' - avocado-ext-connect-config: - types: - - confext - version: "0.1.0" - overlay: overlay # Sensor support sensors: @@ dev: extensions: - app - - avocado-ext-connect-config - sensorscargo fmt,cargo clippy --all-targets -- -D warningsand the fullcargo testpass locally.Please squash merge (bot commits are unsigned; the squash commit is signed by GitHub).