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 { text: Some(text), .. }) => Ok(text.clone()),
|
||||
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
|
||||
/// `- #n title`; none, and nothing was found.
|
||||
fn search(&self, request: &ReadRequest) -> Option<String> {
|
||||
let ReadRequest::Repo(target) = request else { return None };
|
||||
let (repo, words) = target.split_once("?q=")?;
|
||||
let (repo, words) = (repo.to_lowercase(), word_tokens(words));
|
||||
let listed: Vec<String> = self
|
||||
.0
|
||||
.iter()
|
||||
.filter(|entry| entry.kind == "repo")
|
||||
.filter_map(|entry| {
|
||||
let (of, number) = entry.target.split_once('#')?;
|
||||
let title = entry.text.as_deref()?.lines().next()?.trim();
|
||||
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"))
|
||||
}
|
||||
/// 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.
|
||||
fn fixture_search(entries: &[ReadEntry], request: &ReadRequest) -> Option<String> {
|
||||
let ReadRequest::Repo(target) = request else { return None };
|
||||
let (repo, words) = target.split_once("?q=")?;
|
||||
let (repo, words) = (repo.to_lowercase(), word_tokens(words));
|
||||
let listed: Vec<String> = entries
|
||||
.iter()
|
||||
.filter(|entry| entry.kind == "repo")
|
||||
.filter_map(|entry| {
|
||||
let (of, number) = entry.target.split_once('#')?;
|
||||
let title = entry.text.as_deref()?.lines().next()?.trim();
|
||||
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"))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue