Persona harness fix-up: the fixture search is a free function, so the public surface is unchanged
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60edbb7be3
commit
05dffd6327
1 changed files with 18 additions and 21 deletions
|
|
@ -347,31 +347,28 @@ impl ReadSource for ReadFixture {
|
||||||
Some(ReadEntry { refused: Some(why), .. }) => Err(*why),
|
Some(ReadEntry { refused: Some(why), .. }) => Err(*why),
|
||||||
Some(ReadEntry { text: Some(text), .. }) => Ok(text.clone()),
|
Some(ReadEntry { text: Some(text), .. }) => Ok(text.clone()),
|
||||||
Some(_) => Err(ReadFailure::NotFound),
|
Some(_) => Err(ReadFailure::NotFound),
|
||||||
None => self.search(request).ok_or(ReadFailure::NotFound),
|
None => fixture_search(&self.0, request).ok_or(ReadFailure::NotFound),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReadFixture {
|
/// A search of a repo by the titles of its recorded pull requests and issues: each whose title holds every word, as
|
||||||
/// A search of a repo by the titles of its recorded pull requests and issues: each whose title holds every word, as
|
/// `- #n title`; none, and nothing was found.
|
||||||
/// `- #n title`; none, and nothing was found.
|
fn fixture_search(entries: &[ReadEntry], request: &ReadRequest) -> Option<String> {
|
||||||
fn search(&self, request: &ReadRequest) -> Option<String> {
|
let ReadRequest::Repo(target) = request else { return None };
|
||||||
let ReadRequest::Repo(target) = request else { return None };
|
let (repo, words) = target.split_once("?q=")?;
|
||||||
let (repo, words) = target.split_once("?q=")?;
|
let (repo, words) = (repo.to_lowercase(), word_tokens(words));
|
||||||
let (repo, words) = (repo.to_lowercase(), word_tokens(words));
|
let listed: Vec<String> = entries
|
||||||
let listed: Vec<String> = self
|
.iter()
|
||||||
.0
|
.filter(|entry| entry.kind == "repo")
|
||||||
.iter()
|
.filter_map(|entry| {
|
||||||
.filter(|entry| entry.kind == "repo")
|
let (of, number) = entry.target.split_once('#')?;
|
||||||
.filter_map(|entry| {
|
let title = entry.text.as_deref()?.lines().next()?.trim();
|
||||||
let (of, number) = entry.target.split_once('#')?;
|
let held = word_tokens(title);
|
||||||
let title = entry.text.as_deref()?.lines().next()?.trim();
|
(of.to_lowercase() == repo && words.iter().all(|word| held.contains(word))).then(|| format!("- #{number} {title}"))
|
||||||
let held = word_tokens(title);
|
})
|
||||||
(of.to_lowercase() == repo && words.iter().all(|word| held.contains(word))).then(|| format!("- #{number} {title}"))
|
.collect();
|
||||||
})
|
(!listed.is_empty()).then(|| listed.join("\n"))
|
||||||
.collect();
|
|
||||||
(!listed.is_empty()).then(|| listed.join("\n"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue