Repository navigation
Add XML managed-region comment support to cargo-anvil - #237
Open
martin-kolinek wants to merge 1 commit into
Open
martin-kolinek wants to merge 1 commit into
martin-kolinek wants to merge 1 commit into
Conversation
Add complete-line XML comment markers to the managed-region engine, preserve drift and retirement behavior, and document the syntax for XML/MSBuild hosts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f6acf7bf-8e45-4591-9cee-fbcd22647f01
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Syntax migration can duplicate regions, and introducing a region into an existing XML document places it outside the root element.
5 open findings
Absent XML regions are inserted outside the document root · New Syntax changes duplicate regions instead of migrating or refusing · New Test should assert the complete canonical syntax representation · New Test should assert the complete deterministic refusal message · New Negative test should assert the complete deterministic error message · New
What changed in this PR
Adds XML/MSBuild managed-region marker support to cargo-anvil.
Changes:
- Adds XML marker rendering, parsing, repair, and retirement.
- Extends checksum representation and lifecycle tests.
- Documents XML managed-region behavior.
| File | Description |
|---|---|
src/run.rs |
Adds XML recovery and retirement handling. |
src/region.rs |
Implements XML marker syntax. |
src/emit/managed_region.rs |
Tests XML reconciliation. |
src/catalog/builder.rs |
Adds XML syntax checksum tag. |
docs/design/updates.md |
Documents XML update behavior. |
docs/design/README.md |
Updates the managed-region contract. |
docs/design/extensibility.md |
Documents XML syntax for catalogs. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
| match self { | ||
| Self::Hash => format!("# {direction} anvil-managed: {id}"), | ||
| Self::SlashSlash => format!("// {direction} anvil-managed: {id}"), | ||
| Self::Xml => format!("<!-- {direction} anvil-managed: {id} -->"), |
Comment on lines
+198
to
+199
| // by `push_region_at` when it plans the region, with that region's declared | ||
| // comment syntax. |
| syntax: CommentSyntax::Xml, | ||
| }); | ||
|
|
||
| assert!(canonical_repr(®ion).contains("xml")); |
| let edited = host.replace("old.proj", "user.proj"); | ||
| let refusal = plan_managed_region(&manifest, Some(&edited), request).unwrap_err(); | ||
| assert_eq!(refusal.remedy, RefusalRemedy::EditedRegion); | ||
| assert!(refusal.reason.to_string().contains("contains edits")); |
Comment on lines
+2338
to
+2343
| assert!( | ||
| find_region(text, "x", CommentSyntax::Xml) | ||
| .unwrap_err() | ||
| .to_string() | ||
| .contains("no closing sentinel") | ||
| ); |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #237 +/- ##
========================================
+ Coverage 98.9% 99.6% +0.7%
========================================
Files 304 23 -281
Lines 44436 2974 -41462
========================================
- Hits 43975 2964 -41011
+ Misses 461 10 -451
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.


🤖: Adds XML-style managed-region comment support for XML/MSBuild hosts.
Design and behavior
CommentSyntax::Xmlwith complete-line markers such as<!-- >>> anvil-managed: anvil-cloudbuild-projects -->.Tests
Validation
just anvil-fmt --fix— passedcargo test -p cargo-anvil xml --lib— passed (7 tests)cargo test -p cargo-anvil --lib --quiet— passed (613 tests)just anvil-clippy— passedjust anvil-pr-fast— passedjust anvil-pr-fastis the repository's partial local PR tier; the remaining complete-tier groups are left to PR checks.