Files
tolaria/src/hooks/commands/gitCommands.ts
Test 1ae1377b2d refactor: split useCommandRegistry into domain command builders
Extract command definitions into focused domain modules under
src/hooks/commands/ (navigation, note, git, view, settings, type, filter).
useCommandRegistry becomes a thin assembler. Fixes CodeScene cc=39 brain
method — all new files score 9.58–10.0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 22:59:54 +02:00

21 lines
1.1 KiB
TypeScript

import type { CommandAction } from './types'
import type { SidebarSelection } from '../../types'
interface GitCommandsConfig {
modifiedCount: number
onCommitPush: () => void
onPull?: () => void
onResolveConflicts?: () => void
onSelect: (sel: SidebarSelection) => void
}
export function buildGitCommands(config: GitCommandsConfig): CommandAction[] {
const { modifiedCount, onCommitPush, onPull, onResolveConflicts, onSelect } = config
return [
{ id: 'commit-push', label: 'Commit & Push', group: 'Git', keywords: ['git', 'save', 'sync'], enabled: modifiedCount > 0, execute: onCommitPush },
{ id: 'git-pull', label: 'Pull from Remote', group: 'Git', keywords: ['git', 'pull', 'fetch', 'download', 'sync', 'remote'], enabled: true, execute: () => onPull?.() },
{ id: 'resolve-conflicts', label: 'Resolve Conflicts', group: 'Git', keywords: ['conflict', 'merge', 'git', 'sync'], enabled: true, execute: () => onResolveConflicts?.() },
{ id: 'view-changes', label: 'View Pending Changes', group: 'Git', keywords: ['modified', 'diff'], enabled: true, execute: () => onSelect({ kind: 'filter', filter: 'changes' }) },
]
}