MCPcopy Create free account
hub / github.com/JordanCoin/codemap / formatFileImportersOutput

Function formatFileImportersOutput

cmd/hooks_test.go:457–496  ·  view source on GitHub ↗

formatFileImportersOutput is the core output logic extracted for testing This mirrors checkFileImporters but takes hubInfo directly instead of calling getHubInfo

(info *hubInfo, filePath string)

Source from the content-addressed store, hash-verified

455// formatFileImportersOutput is the core output logic extracted for testing
456// This mirrors checkFileImporters but takes hubInfo directly instead of calling getHubInfo
457func formatFileImportersOutput(info *hubInfo, filePath string) {
458 if info == nil {
459 return
460 }
461
462 importers := info.Importers[filePath]
463 if len(importers) >= 3 {
464 fmt.Println()
465 fmt.Printf("⚠️ HUB FILE: %s\n", filePath)
466 fmt.Printf(" Imported by %d files - changes have wide impact!\n", len(importers))
467 fmt.Println()
468 fmt.Println(" Dependents:")
469 for i, imp := range importers {
470 if i >= 5 {
471 fmt.Printf(" ... and %d more\n", len(importers)-5)
472 break
473 }
474 fmt.Printf(" • %s\n", imp)
475 }
476 fmt.Println()
477 } else if len(importers) > 0 {
478 fmt.Println()
479 fmt.Printf("📍 File: %s\n", filePath)
480 fmt.Printf(" Imported by %d file(s): %s\n", len(importers), strings.Join(importers, ", "))
481 fmt.Println()
482 }
483
484 // Also check if this file imports any hubs
485 imports := info.Imports[filePath]
486 var hubImports []string
487 for _, imp := range imports {
488 if info.isHub(imp) {
489 hubImports = append(hubImports, imp)
490 }
491 }
492 if len(hubImports) > 0 {
493 fmt.Printf(" Imports %d hub(s): %s\n", len(hubImports), strings.Join(hubImports, ", "))
494 fmt.Println()
495 }
496}
497
498// TestPromptFileMentionDetection tests the regex patterns for detecting file mentions
499func TestPromptFileMentionDetection(t *testing.T) {

Callers 1

Calls 1

isHubMethod · 0.80

Tested by

no test coverage detected