Documentation
¶
Index ¶
- func BuildQuery(baseQuery string, group string, revisions []string, lang string, ...) string
- func DiscoverVersions(mintignoreEntries []string) []string
- type Cache
- type Client
- func (c *Client) GetFileContent(ctx context.Context, repo, revision, path string) (*FileContent, error)
- func (c *Client) Search(ctx context.Context, query string, searchType SearchType, maxResults int) <-chan SearchEvent
- func (c *Client) SearchSync(ctx context.Context, query string, searchType SearchType, maxResults int) (*SearchResult, error)
- type ClientOption
- type FileContent
- type Filter
- type Highlight
- type Match
- type MatchType
- type RepoGroup
- type SearchEvent
- type SearchProgress
- type SearchResult
- type SearchType
- type SkippedReason
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildQuery ¶
func BuildQuery(baseQuery string, group string, revisions []string, lang string, filePattern string) string
BuildQuery assembles a Sourcegraph search query with filters.
func DiscoverVersions ¶
DiscoverVersions extracts unique version prefixes from .mintignore entries matching the pattern "X.Y.Z/...". Returns versions sorted descending by semver. Falls back to ["main"] if none found.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
Cache is a thread-safe TTL cache with a maximum entry count.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides access to Sourcegraph's code search and file content APIs.
func (*Client) GetFileContent ¶
func (c *Client) GetFileContent(ctx context.Context, repo, revision, path string) (*FileContent, error)
GetFileContent fetches a file's content from a repository via GraphQL. Results are cached by repo@rev:path.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query string, searchType SearchType, maxResults int) <-chan SearchEvent
Search streams search results via a channel. The channel is closed when the search completes or the context is cancelled.
func (*Client) SearchSync ¶
func (c *Client) SearchSync(ctx context.Context, query string, searchType SearchType, maxResults int) (*SearchResult, error)
SearchSync performs a search and returns all results at once.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures a Client.
func WithHTTPClient ¶
func WithHTTPClient(hc *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client.
func WithInstanceURL ¶
func WithInstanceURL(url string) ClientOption
WithInstanceURL sets the Sourcegraph instance URL.
func WithToken ¶
func WithToken(token string) ClientOption
WithToken sets the Sourcegraph access token.
type FileContent ¶
type FileContent struct {
Repository string
Revision string
Path string
Content string
ByteSize int
}
FileContent is the content of a single file from a repository.
type Match ¶
type Match struct {
Type MatchType
Repository string
Revision string
Path string
LineNumber int
Content string
Highlights []Highlight
SymbolName string
SymbolKind string
}
Match represents a single search result match.
type RepoGroup ¶
RepoGroup defines a preset repository filter.
func BazelRepoGroups ¶
func BazelRepoGroups() []RepoGroup
BazelRepoGroups returns the preset Bazel repository groups.
type SearchEvent ¶
type SearchEvent struct {
Type string // "matches", "filters", "progress", "done", "error"
Matches []Match // populated for "matches"
Filters []Filter // populated for "filters"
Progress SearchProgress // populated for "progress" and "done"
Error string // populated for "error"
}
SearchEvent is a typed event emitted on the search channel.
type SearchProgress ¶
type SearchProgress struct {
MatchCount int
Duration int // milliseconds
Done bool
Skipped []SkippedReason
}
SearchProgress reports the search execution state.
type SearchResult ¶
type SearchResult struct {
Matches []Match
Filters []Filter
Progress SearchProgress
}
SearchResult aggregates all events from a completed search.
type SearchType ¶
type SearchType string
SearchType selects the search mode.
const ( SearchKeyword SearchType = "keyword" SearchStandard SearchType = "standard" SearchRegexp SearchType = "regexp" )
type SkippedReason ¶
SkippedReason describes why some results were omitted.