2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { disposableTimeout } from '../../../base/common/async.js';
7
>
import { IExpression, ParsedExpression, parse } from '../../../base/common/glob.js';
8
>
import { Disposable, DisposableMap, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../base/common/lifecycle.js';
9
>
import { extUriBiasedIgnorePathCase } from '../../../base/common/resources.js';
10
>
import { URI } from '../../../base/common/uri.js';
11
>
import { FileChangesEvent, IFileService } from '../../files/common/files.js';
12
>
import { createDecorator } from '../../instantiation/common/instantiation.js';
13
>
import { ILogService } from '../../log/common/log.js';
14
>
15
>
export const IAgentHostFileMonitorService = createDecorator<IAgentHostFileMonitorService>('agentHostFileMonitorService');
16
>
17
>
export const DEFAULT_AGENT_HOST_WATCH_EXCLUDES: readonly string[] = Object.freeze([
18
>
'**/.git',
19
>
'**/.git/lfs/**',
20
>
'**/.git/logs/**',
21
>
'**/.git/objects/**',
22
>
'**/.git/subtree-cache/**',
23
>
'**/.git/**/*.lock',
24
>
'**/.git/**/FETCH_HEAD',
25
>
'**/.git/**/fsmonitor--daemon/**',
26
>
'**/*.watchman-cookie-*',
27
>
]);
28
>
29
>
export interface IAgentHostFileMonitorOptions {
30
>
readonly excludes?: readonly string[];
31
>
readonly debounceMs?: number;
32
>
}
33
>
34
>
export interface IAgentHostFileMonitorService extends IDisposable {
35
>
readonly _serviceBrand: undefined;
36
>
acquire(folder: URI, callback: () => void, options?: IAgentHostFileMonitorOptions): IDisposable | undefined;
37
>
}
38
>
39
>
interface IMonitorEntry extends IDisposable {
40
>
readonly folder: URI;
41
>
readonly callbacks: Set<() => void>;
42
>
readonly debounce: MutableDisposable<IDisposable>;
43
>
readonly debounceMs: number;
44
>
readonly excludeMatcher: ParsedExpression;
45
>
}
46
>
47
function normalizeExcludes(excludes: readonly string[]): readonly string[] {
48
return [...excludes].sort();
49
}
51
function parseExcludes(excludes: readonly string[]): ParsedExpression {
52
const expression: IExpression = Object.create(null);