mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 02:54:31 -07:00
Add Folder Trust Support To Hooks (#15325)
This commit is contained in:
@@ -6,19 +6,9 @@
|
||||
|
||||
import type { Config } from '../config/config.js';
|
||||
import type { HookDefinition, HookConfig } from './types.js';
|
||||
import { HookEventName } from './types.js';
|
||||
import { HookEventName, ConfigSource } from './types.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
|
||||
/**
|
||||
* Configuration source levels in precedence order (highest to lowest)
|
||||
*/
|
||||
export enum ConfigSource {
|
||||
Project = 'project',
|
||||
User = 'user',
|
||||
System = 'system',
|
||||
Extensions = 'extensions',
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook registry entry with source information
|
||||
*/
|
||||
@@ -111,7 +101,13 @@ export class HookRegistry {
|
||||
// Get hooks from the main config (this comes from the merged settings)
|
||||
const configHooks = this.config.getHooks();
|
||||
if (configHooks) {
|
||||
this.processHooksConfiguration(configHooks, ConfigSource.Project);
|
||||
if (this.config.isTrustedFolder()) {
|
||||
this.processHooksConfiguration(configHooks, ConfigSource.Project);
|
||||
} else {
|
||||
debugLogger.warn(
|
||||
'Project hooks disabled because the folder is not trusted.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Get hooks from extensions
|
||||
@@ -189,6 +185,9 @@ export class HookRegistry {
|
||||
} as HookRegistryEntry);
|
||||
const isDisabled = disabledHooks.includes(hookName);
|
||||
|
||||
// Add source to hook config
|
||||
hookConfig.source = source;
|
||||
|
||||
this.entries.push({
|
||||
config: hookConfig,
|
||||
source,
|
||||
|
||||
Reference in New Issue
Block a user