Repository navigation
fix(connect): keep comments after the connect-config extension on clean - #449
Closed
avocado-connect[bot] wants to merge 1 commit into
Closed
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 line and comment after avocado-ext-connect-config as part of its block, 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 child line; trailing blanks and comments stay with what follows. Fixes #447
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the configuration-cleanup change that preserves trailing comments and blank lines.
No open issues 🎉
What changed in this PR
Fixes #447 by preserving comments and blank lines after avocado-ext-connect-config when avocado connect clean edits avocado.yaml.
Changes:
- Ends extension deletion at the last nonblank, non-comment child line, preserving trailing comments and spacing.
- Adds regression tests for comments above the next extension and section headers after the last extension, checking exact output and YAML validity.
- Documents the fix in the changelog.
| File | Description |
|---|---|
src/utils/config_edit.rs |
Adjusts the deletion boundary and adds two comment-preservation regression tests. |
CHANGELOG.md |
Adds an unreleased entry describing the cleanup fix. |
Review effort: Balanced
Contributor
|
duplicate of #448 |
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 definition. It also deleted the blank lines and comments after that definition. That means a comment above the next extension is lost. If connect-config is the last extension, a column-0 section header such as## Runtimesis lost too. Expected: only the connect-config definition and its runtime entry are removed.Root cause
remove_extension_definition(src/utils/config_edit.rs) moved the end of the block forward on every blank or comment line after the extension, at any indent. It stopped only at the next key. So everything between the last child line and the next key was deleted.remove_runtime_extension_entryremoves only the matching- avocado-ext-connect-configline, so it doesn't have this bug.Fix
The block now ends at its last child line that is indented deeper than the extension key. A blank line or comment is part of the block only if a child line comes after it. Trailing blank lines and comments stay with whatever comes next. This is the same rule #443 uses for the top-level
connect:block. Once #443 lands, the two loops could share one helper.Reproduction
I ran
avocado connect clean(main, 2342bc8) on theavocado.yamlfrom the issue.Before,
# Sensor supportand the blank line before it were removed:After, only the extension definition is removed:
With connect-config as the last extension, the
##/## Runtimes/##header used to be deleted. It's now kept.I parsed the before and after files, and they give the same config: the same extensions and the same runtime lists. The bug changed only the text of
avocado.yaml, never what install, build or provision see.Tests
test_remove_connect_config_extension_keeps_comment_above_next_extensionandtest_remove_connect_config_extension_keeps_header_after_last_extension. Both fail on main and pass with this fix. Both check the exact output and that it still parses as YAML.cargo fmt --check,cargo clippy --all-targets -- -D warningsand the fullcargo testpass.Hardware
The jetson-orin-nano isn't set up as a test board on the bench. I'll post the Thor board result on #447 and as a
rubicon / jetson-agx-thorcheck on this commit.Please squash merge.