Skip to content

Commit

Permalink
Fix search in GraphQL with non symetric filters (#1315)
Browse files Browse the repository at this point in the history
The filter was applied twice in the index tree, resulting in paths not
matching the searched tree.

Change: fix-search
  • Loading branch information
christian-schilling authored Feb 28, 2024
1 parent b6a0e8b commit 5e414ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion josh-core/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ impl Revision {
) -> FieldResult<Option<Vec<SearchResult>>> {
let max_complexity = max_complexity.unwrap_or(6) as usize;
let transaction = context.transaction.lock()?;
let ifilterobj = filter::chain(self.filter, filter::parse(":SQUASH:INDEX")?);
let ifilterobj = filter::parse(":SQUASH:INDEX")?;
let tree = transaction.repo().find_commit(self.commit_id)?.tree()?;

let tree = filter::apply(&transaction, self.filter, tree)?;
Expand Down
18 changes: 18 additions & 0 deletions tests/experimental/indexer.t
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@
]
}
}
$ josh-filter :/ -g 'query { rev(at: "refs/heads/master", filter: ":/sub2") { results: search(string: "e") { path { path }, matches { line, text }} }}'
{
"rev": {
"results": [
{
"path": {
"path": "file3"
},
"matches": [
{
"line": 1,
"text": "One more to see what happens"
}
]
}
]
}
}
$ git diff ${EMPTY_TREE}..refs/heads/index
diff --git a/SUB1 b/SUB1
Expand Down

0 comments on commit 5e414ce

Please sign in to comment.