MCPcopy Create free account
hub / github.com/cli/cli / executeSearch

Function executeSearch

pkg/cmd/skills/search/search.go:729–743  ·  view source on GitHub ↗

executeSearch performs a single GitHub Code Search API call.

(client *api.Client, host, query string, page, pageSize int)

Source from the content-addressed store, hash-verified

727
728// executeSearch performs a single GitHub Code Search API call.
729func executeSearch(client *api.Client, host, query string, page, pageSize int) (*codeSearchResult, error) {
730 apiPath, err := safeurl.JoinPath("search", "code")
731 if err != nil {
732 return nil, err
733 }
734 apiPath.SetQuery("q", query)
735 apiPath.SetQuery("per_page", strconv.Itoa(pageSize))
736 apiPath.SetQuery("page", strconv.Itoa(page))
737 var result codeSearchResult
738 err = client.REST(host, "GET", apiPath.String(), nil, &result)
739 if err != nil && isRateLimitError(err) {
740 return nil, fmt.Errorf("%s", rateLimitErrorMessage)
741 }
742 return &result, err
743}
744
745// fetchPrimaryPages fetches enough API pages from GitHub Code Search to
746// cover the requested display page, accounting for filtering losses.

Callers 2

searchByKeywordFunction · 0.85
fetchPrimaryPagesFunction · 0.85

Calls 6

JoinPathFunction · 0.92
isRateLimitErrorFunction · 0.85
SetQueryMethod · 0.80
RESTMethod · 0.65
StringMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected