Skip to content

Commit 226d3b7

Browse files
committed
Syncs commit & search context in commit details
- Manages commit and search context together
1 parent 8f82e8c commit 226d3b7

File tree

5 files changed

+121
-65
lines changed

5 files changed

+121
-65
lines changed

src/git/search.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import type { GitRevisionReference } from './models/reference';
66
import type { GitUser } from './models/user';
77
import { isSha, shortenRevision } from './utils/revision.utils';
88

9+
export interface GitCommitSearchContext {
10+
readonly query: SearchQuery;
11+
readonly queryFilters: SearchQueryFilters;
12+
readonly matchedFiles: ReadonlyArray<Readonly<{ readonly path: string }>>;
13+
}
14+
915
export interface GitGraphSearchResultData {
1016
readonly date: number;
1117
readonly i: number;

src/git/utils/search.utils.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { GitCommitSearchContext } from '../search';
2+
3+
export function areSearchContextsEqual(
4+
a: GitCommitSearchContext | undefined,
5+
b: GitCommitSearchContext | undefined,
6+
deep: boolean,
7+
): boolean {
8+
if (a === b) return true;
9+
if (a == null || b == null) return false;
10+
11+
return (
12+
a.query === b.query &&
13+
(!deep ||
14+
(a.queryFilters.files === b.queryFilters.files &&
15+
a.queryFilters.refs === b.queryFilters.refs &&
16+
a.queryFilters.type === b.queryFilters.type &&
17+
a.matchedFiles.length === b.matchedFiles.length &&
18+
a.matchedFiles.every((f, i) => f.path === b.matchedFiles[i].path)))
19+
);
20+
}

0 commit comments

Comments
 (0)