Skip to content

Commit

Permalink
Fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Arne Durr committed Dec 18, 2024
1 parent cdc49bd commit 918d351
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/components/workbench/Workbench.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
14 changes: 4 additions & 10 deletions app/lib/git/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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) => {
Expand All @@ -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' },
Expand All @@ -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,
Expand Down

0 comments on commit 918d351

Please sign in to comment.