Skip to content

Add XML managed-region comment support to cargo-anvil - #237

Open
martin-kolinek wants to merge 1 commit into
mainfrom
copilot/cargo-anvil-xml-regions
Open

martin-kolinek wants to merge 1 commit into
mainfrom
copilot/cargo-anvil-xml-regions

Conversation

@martin-kolinek

Copy link
Copy Markdown
Collaborator

🤖: Adds XML-style managed-region comment support for XML/MSBuild hosts.

Design and behavior

  • Adds CommentSyntax::Xml with complete-line markers such as <!-- >>> anvil-managed: anvil-cloudbuild-projects -->.
  • Reuses the existing parser, writer, marker recovery, drift detection, reconciliation, and retirement paths without host-specific special cases.
  • Requires marker text to occupy a complete XML comment line; embedded or extended marker-like text remains user content.
  • Preserves Hash and SlashSlash marker behavior.
  • Updates the current cargo-anvil design contract for XML/MSBuild hosts.

Tests

  • XML rendering and insertion
  • Existing-region discovery and update with surrounding XML preservation
  • Unpaired/malformed marker refusal
  • Marker-like non-comment-line text ignored
  • Existing drift/reconciliation behavior
  • XML marker recovery and retirement

Validation

  • just anvil-fmt --fix — passed
  • cargo test -p cargo-anvil xml --lib — passed (7 tests)
  • cargo test -p cargo-anvil --lib --quiet — passed (613 tests)
  • just anvil-clippy — passed
  • just anvil-pr-fast — passed

just anvil-pr-fast is the repository's partial local PR tier; the remaining complete-tier groups are left to PR checks.

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
Copilot AI balanced review requested due to automatic review settings October 8, 2026 13:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
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(&region).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-commenter

Codecov Comments Bot (codecov-commenter) commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.93750% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.6%. Comparing base (3cd0306) to head (8a261d7).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/cargo-anvil/src/region.rs 82.6% 9 Missing ⚠️
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     
Flag Coverage Δ
linux 99.6% <85.9%> (+0.7%) ⬆️
linux-arm 99.6% <85.9%> (+0.7%) ⬆️
scheduled ?
windows 99.6% <85.9%> (+0.8%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants