detectNetworkFromRepo scans the current working directory for ecosystem indicator files and returns a deduplicated, sorted list of network bucket names to add.
()
| 823 | // detectNetworkFromRepo scans the current working directory for ecosystem indicator |
| 824 | // files and returns a deduplicated, sorted list of network bucket names to add. |
| 825 | func detectNetworkFromRepo() []string { |
| 826 | cwd, err := os.Getwd() |
| 827 | if err != nil { |
| 828 | return nil |
| 829 | } |
| 830 | |
| 831 | seen := map[string]struct { |
| 832 | }{} |
| 833 | for _, m := range repoLanguageMarkers { |
| 834 | var found bool |
| 835 | if strings.ContainsAny(m.file, "*?[") { |
| 836 | // Glob pattern |
| 837 | matches, err := filepath.Glob(filepath.Join(cwd, m.file)) |
| 838 | found = err == nil && len(matches) > 0 |
| 839 | } else { |
| 840 | _, err := os.Stat(filepath.Join(cwd, m.file)) |
| 841 | found = err == nil |
| 842 | } |
| 843 | if found && !setutil.Contains(seen, m.bucket) { |
| 844 | seen[m.bucket] = struct { |
| 845 | }{} |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | buckets := sliceutil.SortedKeys(seen) |
| 850 | return buckets |
| 851 | } |