(
workspaceId: string,
baseRef?: string | null
)
| 5873 | } |
| 5874 | |
| 5875 | async getProjectGitStatuses( |
| 5876 | workspaceId: string, |
| 5877 | baseRef?: string | null |
| 5878 | ): Promise<ProjectGitStatusResult[]> { |
| 5879 | assert(workspaceId.trim().length > 0, "getProjectGitStatuses requires a workspaceId"); |
| 5880 | |
| 5881 | const metadataResult = await this.aiService.getWorkspaceMetadata(workspaceId); |
| 5882 | if (!metadataResult.success) { |
| 5883 | throw new Error(`Failed to get workspace metadata: ${metadataResult.error}`); |
| 5884 | } |
| 5885 | |
| 5886 | const metadata = metadataResult.data; |
| 5887 | assert(metadata, `Workspace ${workspaceId} metadata is required for git status checks`); |
| 5888 | |
| 5889 | const projects = getProjects(metadata); |
| 5890 | assert(projects.length > 0, `Workspace ${workspaceId} must include at least one project`); |
| 5891 | |
| 5892 | const normalizedProjectPaths = projects.map((project) => { |
| 5893 | assert( |
| 5894 | project.projectPath.trim().length > 0, |
| 5895 | `Workspace ${workspaceId} project ${project.projectName} is missing a projectPath` |
| 5896 | ); |
| 5897 | assert( |
| 5898 | project.projectName.trim().length > 0, |
| 5899 | `Workspace ${workspaceId} project ${project.projectPath} is missing a projectName` |
| 5900 | ); |
| 5901 | const normalizedProjectPath = normalizeRepoRootProjectPath(project.projectPath); |
| 5902 | assert( |
| 5903 | normalizedProjectPath.length > 0, |
| 5904 | `Workspace ${workspaceId} project ${project.projectName} normalized to an empty projectPath` |
| 5905 | ); |
| 5906 | return normalizedProjectPath; |
| 5907 | }); |
| 5908 | const uniqueNormalizedProjectPaths = new Set(normalizedProjectPaths); |
| 5909 | assert( |
| 5910 | uniqueNormalizedProjectPaths.size === normalizedProjectPaths.length, |
| 5911 | `Workspace ${workspaceId} has duplicate project paths` |
| 5912 | ); |
| 5913 | |
| 5914 | const script = generateGitStatusScript(baseRef ?? undefined); |
| 5915 | const results: ProjectGitStatusResult[] = []; |
| 5916 | |
| 5917 | for (const project of projects) { |
| 5918 | try { |
| 5919 | const result = await this.executeBash(workspaceId, script, { |
| 5920 | cwdMode: "repo-root", |
| 5921 | repoRootProjectPath: project.projectPath, |
| 5922 | timeout_secs: 5, |
| 5923 | }); |
| 5924 | |
| 5925 | if (!result.success) { |
| 5926 | results.push({ |
| 5927 | projectPath: project.projectPath, |
| 5928 | projectName: project.projectName, |
| 5929 | gitStatus: null, |
| 5930 | error: result.error, |
| 5931 | }); |
| 5932 | continue; |
no test coverage detected