MCPcopy Create free account
hub / github.com/github/gh-aw / buildOrgWorkflowSearchQuery

Function buildOrgWorkflowSearchQuery

pkg/cli/update_org_search.go:49–77  ·  view source on GitHub ↗

buildOrgWorkflowSearchQuery constructs the org-mode code-search query for lock.yml workflow files. When workflowNames is empty, or every candidate normalizes away, it falls back to the base query and relies on the later per-repo workflow scan to enforce any requested filters.

(org string, workflowNames []string)

Source from the content-addressed store, hash-verified

47// normalizes away, it falls back to the base query and relies on the later
48// per-repo workflow scan to enforce any requested filters.
49func buildOrgWorkflowSearchQuery(org string, workflowNames []string) string {
50 base := fmt.Sprintf(`org:%s path:.github/workflows filename:.lock.yml`, org)
51 if len(workflowNames) == 0 {
52 return base
53 }
54
55 filenameFilters := make([]string, 0, len(workflowNames))
56 seen := make(map[string]struct{}, len(workflowNames))
57 for _, workflowName := range workflowNames {
58 normalized := normalizeWorkflowID(workflowName)
59 if normalized == "" || normalized == "." {
60 continue
61 }
62 filename := normalized + ".lock.yml"
63 if _, ok := seen[filename]; ok {
64 continue
65 }
66 seen[filename] = struct{}{}
67 filenameFilters = append(filenameFilters, "filename:"+filename)
68 }
69 if len(filenameFilters) == 0 {
70 // CLI validation already rejects empty workflow names, so this fallback is
71 // primarily a safety net for non-CLI callers and tests.
72 return base
73 }
74
75 slices.Sort(filenameFilters)
76 return base + " (" + strings.Join(filenameFilters, " OR ") + ")"
77}
78
79// searchOrgReposByQuery paginates through GitHub code-search results for the given
80// query, deduplicates by repository full name, and returns a deterministically

Callers 2

searchOrgWorkflowReposFunction · 0.85

Calls 1

normalizeWorkflowIDFunction · 0.85

Tested by 1