From 32cb89d32958e9480340dfbaa4723c0be20fd3d1 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sun, 11 May 2025 13:01:43 +0200 Subject: [PATCH] Migrate useGitOperations --- .../{useGitOperations.js => useGitOperations.ts} | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) rename app/src/hooks/{useGitOperations.js => useGitOperations.ts} (77%) diff --git a/app/src/hooks/useGitOperations.js b/app/src/hooks/useGitOperations.ts similarity index 77% rename from app/src/hooks/useGitOperations.js rename to app/src/hooks/useGitOperations.ts index bf8d68c..426c3f7 100644 --- a/app/src/hooks/useGitOperations.js +++ b/app/src/hooks/useGitOperations.ts @@ -3,10 +3,15 @@ import { notifications } from '@mantine/notifications'; import { pullChanges, commitAndPush } from '../api/git'; import { useWorkspace } from '../contexts/WorkspaceContext'; -export const useGitOperations = () => { +interface UseGitOperationsResult { + handlePull: () => Promise; + handleCommitAndPush: (message: string) => Promise; +} + +export const useGitOperations = (): UseGitOperationsResult => { const { currentWorkspace, settings } = useWorkspace(); - const handlePull = useCallback(async () => { + const handlePull = useCallback(async (): Promise => { if (!currentWorkspace || !settings.gitEnabled) return false; try { @@ -29,11 +34,14 @@ export const useGitOperations = () => { }, [currentWorkspace, settings.gitEnabled]); const handleCommitAndPush = useCallback( - async (message) => { + async (message: string): Promise => { if (!currentWorkspace || !settings.gitEnabled) return false; try { - await commitAndPush(currentWorkspace.name, message); + const commitHash: CommitHash = await commitAndPush( + currentWorkspace.name, + message + ); notifications.show({ title: 'Success', message: 'Successfully committed and pushed changes',