mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
- Extended SetupAPI interface with 20+ missing methods for Cursor, Codex, OpenCode, Gemini, and Copilot CLI integrations - Fixed WorktreeInfo type to include isCurrent and hasWorktree fields - Added null checks for optional API properties across all hooks - Fixed Feature type conflicts between @automaker/types and local definitions - Added missing CLI status hooks for all providers - Fixed type mismatches in mutation callbacks and event handlers - Removed dead code referencing non-existent GlobalSettings properties - Updated mock implementations in electron.ts for all new API methods Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
/**
|
|
* Git Query Hooks
|
|
*
|
|
* React Query hooks for git operations.
|
|
*/
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { getElectronAPI } from '@/lib/electron';
|
|
import { queryKeys } from '@/lib/query-keys';
|
|
import { STALE_TIMES } from '@/lib/query-client';
|
|
|
|
/**
|
|
* Fetch git diffs for a project (main project, not worktree)
|
|
*
|
|
* @param projectPath - Path to the project
|
|
* @param enabled - Whether to enable the query
|
|
* @returns Query result with files and diff content
|
|
*/
|
|
export function useGitDiffs(projectPath: string | undefined, enabled = true) {
|
|
return useQuery({
|
|
queryKey: queryKeys.git.diffs(projectPath ?? ''),
|
|
queryFn: async () => {
|
|
if (!projectPath) throw new Error('No project path');
|
|
const api = getElectronAPI();
|
|
if (!api.git) {
|
|
throw new Error('Git API not available');
|
|
}
|
|
const result = await api.git.getDiffs(projectPath);
|
|
if (!result.success) {
|
|
throw new Error(result.error || 'Failed to fetch diffs');
|
|
}
|
|
return {
|
|
files: result.files ?? [],
|
|
diff: result.diff ?? '',
|
|
};
|
|
},
|
|
enabled: !!projectPath && enabled,
|
|
staleTime: STALE_TIMES.WORKTREES,
|
|
});
|
|
}
|