* Builds a deferred stub for a repository file from a tree entry. Content is empty * and fetched lazily via getDocument for new/changed files only.
( apiBase: string, encodedProject: string, host: string, projectPath: string, ref: string, entry: GitLabTreeEntry )
| 292 | * and fetched lazily via getDocument for new/changed files only. |
| 293 | */ |
| 294 | function treeEntryToStub( |
| 295 | apiBase: string, |
| 296 | encodedProject: string, |
| 297 | host: string, |
| 298 | projectPath: string, |
| 299 | ref: string, |
| 300 | entry: GitLabTreeEntry |
| 301 | ): ExternalDocument { |
| 302 | return { |
| 303 | externalId: `${FILE_PREFIX}${entry.path}`, |
| 304 | title: entry.name || entry.path, |
| 305 | content: '', |
| 306 | contentDeferred: true, |
| 307 | mimeType: 'text/plain', |
| 308 | sourceUrl: buildFileSourceUrl(apiBase, encodedProject, host, projectPath, ref, entry.path), |
| 309 | contentHash: buildFileContentHash(encodedProject, entry.path, entry.id), |
| 310 | metadata: { |
| 311 | contentType: 'file', |
| 312 | title: entry.name || entry.path, |
| 313 | path: entry.path, |
| 314 | }, |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Builds a repository-file document from a fetched (non-raw) file response. Returns |
no test coverage detected