Skip to content

Commit 5e414ce

Browse files
Fix search in GraphQL with non symetric filters (#1315)
The filter was applied twice in the index tree, resulting in paths not matching the searched tree. Change: fix-search
1 parent b6a0e8b commit 5e414ce

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

josh-core/src/graphql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl Revision {
427427
) -> FieldResult<Option<Vec<SearchResult>>> {
428428
let max_complexity = max_complexity.unwrap_or(6) as usize;
429429
let transaction = context.transaction.lock()?;
430-
let ifilterobj = filter::chain(self.filter, filter::parse(":SQUASH:INDEX")?);
430+
let ifilterobj = filter::parse(":SQUASH:INDEX")?;
431431
let tree = transaction.repo().find_commit(self.commit_id)?.tree()?;
432432

433433
let tree = filter::apply(&transaction, self.filter, tree)?;

tests/experimental/indexer.t

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@
8484
]
8585
}
8686
}
87+
$ josh-filter :/ -g 'query { rev(at: "refs/heads/master", filter: ":/sub2") { results: search(string: "e") { path { path }, matches { line, text }} }}'
88+
{
89+
"rev": {
90+
"results": [
91+
{
92+
"path": {
93+
"path": "file3"
94+
},
95+
"matches": [
96+
{
97+
"line": 1,
98+
"text": "One more to see what happens"
99+
}
100+
]
101+
}
102+
]
103+
}
104+
}
87105
88106
$ git diff ${EMPTY_TREE}..refs/heads/index
89107
diff --git a/SUB1 b/SUB1

0 commit comments

Comments
 (0)