Skip to content

Commit 02d7409

Browse files
committed
fix(studio): fetch base64 encoded files from GitLab
1 parent 6586773 commit 02d7409

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/app/src/composables/useGit.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ function createGitLabProvider(options: GitOptions): GitProvider {
224224

225225
try {
226226
const encodedPath = encodeURIComponent(path)
227-
const glFile = await $api(`/repository/files/${encodedPath}/raw?ref=${branch}`)
228-
229-
// Get file metadata
227+
// GitLab API returns base64-encoded content when using /repository/files endpoint (without /raw)
230228
const fileMetadata = await $api(`/repository/files/${encodedPath}?ref=${branch}`)
231229

232230
const gitFile: GitFile = {
@@ -235,8 +233,9 @@ function createGitLabProvider(options: GitOptions): GitProvider {
235233
sha: fileMetadata.blob_id,
236234
size: fileMetadata.size,
237235
url: fileMetadata.file_path,
238-
content: typeof glFile === 'string' ? glFile : undefined,
239-
encoding: fileMetadata.encoding,
236+
content: fileMetadata.content,
237+
encoding: 'base64' as const,
238+
provider: 'gitlab' as const,
240239
}
241240

242241
if (cached) {
@@ -251,13 +250,13 @@ function createGitLabProvider(options: GitOptions): GitProvider {
251250
return null
252251
}
253252

253+
console.error(`Failed to fetch file from GitLab: ${path}`, error)
254+
254255
// For development, show alert. In production, you might want to use a toast notification
255256
if (process.env.NODE_ENV === 'development') {
256257
alert(`Failed to fetch file: ${path}\n${(error as { message?: string }).message || error}`)
257258
}
258259

259-
console.error(`Failed to fetch file from GitLab: ${path}`, error)
260-
261260
return null
262261
}
263262
}

src/app/src/types/git.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ export interface CommitResult {
5959
}
6060

6161
export interface GitFile {
62+
provider: GitProviderType
6263
name: string
6364
path: string
6465
sha: string
6566
size: number
6667
url: string
6768
content?: string
68-
encoding?: string
69+
encoding?: 'utf-8' | 'base64'
6970
}
7071

7172
export interface GithubFile extends GitFile {

0 commit comments

Comments
 (0)