mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-22 15:51:18 -07:00
feat(hooks): add support for friendly names and descriptions (#15174)
This commit is contained in:
@@ -282,6 +282,71 @@ describe('HookPlanner', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should deduplicate based on both name and command', () => {
|
||||
const mockEntries: HookRegistryEntry[] = [
|
||||
{
|
||||
config: {
|
||||
name: 'hook1',
|
||||
type: HookType.Command,
|
||||
command: './same.sh',
|
||||
},
|
||||
source: ConfigSource.Project,
|
||||
eventName: HookEventName.BeforeTool,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
config: {
|
||||
name: 'hook1',
|
||||
type: HookType.Command,
|
||||
command: './same.sh',
|
||||
},
|
||||
source: ConfigSource.User,
|
||||
eventName: HookEventName.BeforeTool,
|
||||
enabled: true,
|
||||
}, // Same name, same command -> deduplicate
|
||||
{
|
||||
config: {
|
||||
name: 'hook2',
|
||||
type: HookType.Command,
|
||||
command: './same.sh',
|
||||
},
|
||||
source: ConfigSource.Project,
|
||||
eventName: HookEventName.BeforeTool,
|
||||
enabled: true,
|
||||
}, // Different name, same command -> distinct
|
||||
{
|
||||
config: {
|
||||
name: 'hook1',
|
||||
type: HookType.Command,
|
||||
command: './different.sh',
|
||||
},
|
||||
source: ConfigSource.Project,
|
||||
eventName: HookEventName.BeforeTool,
|
||||
enabled: true,
|
||||
}, // Same name, different command -> distinct
|
||||
{
|
||||
config: { type: HookType.Command, command: './no-name.sh' },
|
||||
source: ConfigSource.Project,
|
||||
eventName: HookEventName.BeforeTool,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
config: { type: HookType.Command, command: './no-name.sh' },
|
||||
source: ConfigSource.User,
|
||||
eventName: HookEventName.BeforeTool,
|
||||
enabled: true,
|
||||
}, // No name, same command -> deduplicate
|
||||
];
|
||||
|
||||
vi.mocked(mockHookRegistry.getHooksForEvent).mockReturnValue(mockEntries);
|
||||
|
||||
const plan = hookPlanner.createExecutionPlan(HookEventName.BeforeTool);
|
||||
|
||||
expect(plan).not.toBeNull();
|
||||
// hook1:same.sh (deduped), hook2:same.sh, hook1:different.sh, :no-name.sh (deduped)
|
||||
expect(plan!.hookConfigs).toHaveLength(4);
|
||||
});
|
||||
|
||||
it('should match trigger for session events', () => {
|
||||
const mockEntries: HookRegistryEntry[] = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user