forked from TrafficGuard/typedai
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path
8000
codeTaskRepositoryPath.ts
More file actions
28 lines (27 loc) · 1.43 KB
/
codeTaskRepositoryPath.ts
File metadata and controls
28 lines (27 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { join } from 'node:path';
import { systemDir } from '#app/appDirs';
import { logger } from '#o11y/logger';
import type { CodeTask } from '#shared/codeTask/codeTask.model';
export function getCodeTaskRepositoryPath(codeTask: CodeTask): string {
const codeTaskId = codeTask.id;
// Calculate Workspace Path based on codeTask settings
let workspacePath: string;
if (!codeTask.useSharedRepos) {
workspacePath = join(systemDir(), 'codeTask', codeTask.id);
logger.info({ codeTaskId, useSharedRepos: false, workspacePath }, 'Using codeTask-specific workspace path.');
} else {
// Use shared repository workspace
if (codeTask.repositorySource !== 'github' && codeTask.repositorySource !== 'gitlab') {
throw new Error(`Invalid repositorySource "${codeTask.repositorySource}" for shared repository. Must be 'github' or 'gitlab'.`);
}
// Assuming repositoryId is in the format "namespace/repoName" for GitHub/GitLab shared repos
const repoIdParts = codeTask.repositoryId.split('/');
if (repoIdParts.length !== 2 || !repoIdParts[0] || !repoIdParts[1]) {
throw new Error(`Invalid repositoryId format "${codeTask.repositoryId}" for shared repository. Expected "namespace/repoName".`);
}
const [namespace, repoName] = repoIdParts;
workspacePath = join(systemDir(), codeTask.repositorySource, namespace, repoName);
logger.info({ codeTaskId, namespace, repoName, workspacePath }, 'Using shared workspace path.');
}
return workspacePath;
}