diff --git a/app/components/workbench/Workbench.client.tsx b/app/components/workbench/Workbench.client.tsx index aab5c382c..ca36d797b 100644 --- a/app/components/workbench/Workbench.client.tsx +++ b/app/components/workbench/Workbench.client.tsx @@ -132,9 +132,9 @@ export const Workbench = memo(({ chatStarted, isStreaming }: WorkspaceProps) => } }, []); - const getWorkbenchFiles = useCallback((provider: "github" | "gitlab") => { + const getWorkbenchFiles = useCallback((provider: 'github' | 'gitlab') => { const docs = workbenchStore.files.get(); - handleGitPush(provider, docs) + handleGitPush(provider, docs); }, []); return ( diff --git a/app/lib/git/operations.ts b/app/lib/git/operations.ts index c5c88ee91..ae52ddc8f 100644 --- a/app/lib/git/operations.ts +++ b/app/lib/git/operations.ts @@ -3,8 +3,7 @@ import { ensureEncryption, lookupSavedPassword } from '~/lib/auth'; import { Octokit, type RestEndpointMethodTypes } from '@octokit/rest'; import axios from 'axios'; import { extractRelativePath } from '~/utils/diff'; -import type { FileMap } from '../stores/files'; -import type { Dirent } from 'fs'; +import type { FileMap } from '~/lib/stores/files'; export const handleGitPush = async (provider: 'github' | 'gitlab', getFiles: FileMap) => { const repoName = prompt( @@ -81,9 +80,6 @@ const pushToGitHub = async (repoName: string, username: string, token: string, f } } - // Get all files - // const files = workbenchStore.files.get(); - if (!files || Object.keys(files).length === 0) { throw new Error('No files found to push'); } @@ -167,7 +163,6 @@ const pushToGitHub = async (repoName: string, username: string, token: string, f }; const pushToGitLab = async (repoName: string, username: string, token: string, files: FileMap) => { - console.log('files', files); try { const gitlab = axios.create({ baseURL: 'https://gitlab.com/api/v4', @@ -221,8 +216,6 @@ const pushToGitLab = async (repoName: string, username: string, token: string, f throw new Error('No files found to push'); } - console.log('Object.entries(files)', Object.entries(files)); - const actions = await Promise.all( Object.entries(files) .filter((entry) => { @@ -231,6 +224,7 @@ const pushToGitLab = async (repoName: string, username: string, token: string, f }) .map(async ([filePath, dirent]) => { const relativePath = extractRelativePath(filePath); + try { await axios.get(`/projects/${project.id}/repository/files/${encodeURIComponent(relativePath)}`, { params: { ref: project.default_branch || 'main' }, @@ -240,14 +234,14 @@ const pushToGitLab = async (repoName: string, username: string, token: string, f 'Content-Type': 'application/json', }, }); - console.log('Bestand bestaat, gebruik update'); + return { action: 'update', file_path: relativePath, content: dirent.content, }; } catch (error) { - console.log('Bestand bestaat niet, gebruik create'); + console.error('File on gitlab', error); return { action: 'create', file_path: relativePath,