Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/intent/src/graph_references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,11 @@ fn req_traces_in(document: &Document) -> Vec<ReqTrace> {
{
cursor += 1;
}
let contains_placeholder = bytes.get(cursor) == Some(&b'<');
Comment thread
schickling-assistant marked this conversation as resolved.
Resolved
while cursor > target_start && bytes[cursor - 1] == b'.' {
cursor -= 1;
}
if cursor > target_start {
if cursor > target_start && !contains_placeholder {
traces.push(ReqTrace {
written: line[target_start..cursor].to_string(),
range: line_start + found..line_start + cursor,
Expand Down
19 changes: 10 additions & 9 deletions crates/intent/tests/intent_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ fn graph_json_recognizes_all_supported_requirement_definition_forms() {
.expect("requirements");
fs::write(
h.repo.join("context/intent/spec.md"),
"# Spec\n\nThis builds on [requirements](./requirements.md).\n\nAPP-R02 and R03 constrain the graph.\nreq: APP-R02\nreq: <ID>\nreq: <repo-relative-requirements-path>#<ID>\n",
"# Spec\n\nThis builds on [requirements](./requirements.md).\n\nAPP-R02 and R03 constrain the graph.\nreq: APP-R02\nreq: <ID>\nreq: <repo-relative-requirements-path>#<ID>\nreq: requirements.md#<ID>\nreq: APP-<ID>\n",
)
.expect("spec");

Expand Down Expand Up @@ -511,15 +511,16 @@ fn graph_json_recognizes_all_supported_requirement_definition_forms() {
"missing resolved citation for {target}"
);
}
assert!(
references.iter().all(|reference| {
reference["syntax"] != "req_trace"
|| !reference["written_target"]
.as_str()
.is_some_and(|target| target.contains('<') || target.contains('>'))
}),
"template placeholders must not become requirement traces"
let traces = references
.iter()
.filter(|reference| reference["syntax"] == "req_trace")
.collect::<Vec<_>>();
assert_eq!(
traces.len(),
1,
"template placeholders must not become requirement traces: {traces:#?}"
);
assert_eq!(traces[0]["written_target"], "APP-R02");
}

#[test]
Expand Down
Loading