From b6b72f83a0eee049c485d5c3583f413f2071ef54 Mon Sep 17 00:00:00 2001 From: slokh Date: Wed, 18 Mar 2026 12:39:49 -0700 Subject: [PATCH] fix: stricter version matching in action.yml and workspace root detection - action.yml: Replace index($0, ver) substring match with regex anchored match to prevent partial version collisions (e.g., '1.0' matching '1.0.1') - rust.rs: Use toml_edit parsing instead of string contains to detect workspace root, preventing false matches from comments or strings Amp-Thread-ID: https://ampcode.com/threads/T-019d0268-a225-76d0-951a-b0991bcdda1f Co-authored-by: Amp --- action.yml | 2 +- src/ecosystems/rust.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 471b2d9..373373f 100644 --- a/action.yml +++ b/action.yml @@ -273,7 +273,7 @@ runs: BEGIN { printing=0 } /^## / { if (printing) exit - if (index($0, ver) > 0) { printing=1; next } + if ($0 ~ "^## " ver "[ (]") { printing=1; next } } printing { print } ' "$changelog_file") diff --git a/src/ecosystems/rust.rs b/src/ecosystems/rust.rs index f7a5baf..8b7152f 100644 --- a/src/ecosystems/rust.rs +++ b/src/ecosystems/rust.rs @@ -236,7 +236,8 @@ impl RustAdapter { let candidate = current.join("Cargo.toml"); if candidate.exists() && candidate != manifest_path { let content = std::fs::read_to_string(&candidate)?; - if content.contains("[workspace]") { + let doc: DocumentMut = content.parse()?; + if doc.get("workspace").is_some() { return Ok(current); } }