(root string, info *hubInfo)
| 187 | } |
| 188 | |
| 189 | func buildProjectContext(root string, info *hubInfo) ProjectContext { |
| 190 | ctx := ProjectContext{ |
| 191 | Root: root, |
| 192 | } |
| 193 | |
| 194 | // Get branch |
| 195 | if branch, ok := gitCurrentBranch(root); ok { |
| 196 | ctx.Branch = branch |
| 197 | } |
| 198 | |
| 199 | // Count files and detect languages from daemon state |
| 200 | if state := watch.ReadState(root); state != nil { |
| 201 | ctx.FileCount = state.FileCount |
| 202 | ctx.HubCount = len(state.Hubs) |
| 203 | if len(state.Hubs) > 5 { |
| 204 | ctx.TopHubs = state.Hubs[:5] |
| 205 | } else { |
| 206 | ctx.TopHubs = state.Hubs |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | // Detect languages from multiple sources |
| 211 | langSet := make(map[string]bool) |
| 212 | |
| 213 | // Source 1: dependency graph (importers + imports) |
| 214 | if info != nil { |
| 215 | for file := range info.Importers { |
| 216 | if lang := scanner.DetectLanguage(file); lang != "" { |
| 217 | langSet[lang] = true |
| 218 | } |
| 219 | } |
| 220 | for file := range info.Imports { |
| 221 | if lang := scanner.DetectLanguage(file); lang != "" { |
| 222 | langSet[lang] = true |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Source 2: hubs |
| 228 | for _, hub := range ctx.TopHubs { |
| 229 | if lang := scanner.DetectLanguage(hub); lang != "" { |
| 230 | langSet[lang] = true |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | // Source 3: cheap fallback — scan for manifest files and top-level source files. |
| 235 | // This runs when daemon isn't active and dep graph is empty. |
| 236 | if len(langSet) == 0 { |
| 237 | langSet = detectLanguagesFromFiles(root) |
| 238 | } |
| 239 | |
| 240 | for lang := range langSet { |
| 241 | ctx.Languages = append(ctx.Languages, lang) |
| 242 | } |
| 243 | sort.Strings(ctx.Languages) |
| 244 | |
| 245 | // Fallback file count from quick scan if daemon wasn't available |
| 246 | if ctx.FileCount == 0 && len(ctx.Languages) > 0 { |
no test coverage detected