[mirror] a bluesky bot to post golang projects
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #35 from till/fix-search

fix: search

authored by

Till! and committed by
GitHub
c247b8de 565f3443

+31 -2
+1 -1
go.mod
··· 4 4 5 5 require ( 6 6 github.com/go-redis/redis/v8 v8.11.5 7 + github.com/google/go-github/v39 v39.2.0 7 8 github.com/stretchr/testify v1.11.1 8 9 github.com/tailscale/go-bluesky v0.0.0-20241115170709-693553a07285 9 10 github.com/urfave/cli/v3 v3.8.0 ··· 20 21 github.com/go-logr/logr v1.4.1 // indirect 21 22 github.com/go-logr/stdr v1.2.2 // indirect 22 23 github.com/golang/protobuf v1.5.3 // indirect 23 - github.com/google/go-github/v39 v39.2.0 // indirect 24 24 github.com/google/go-querystring v1.1.0 // indirect 25 25 github.com/klauspost/compress v1.18.2 // indirect 26 26 github.com/klauspost/crc32 v1.3.0 // indirect
+3 -1
internal/content/content.go
··· 27 27 Language: "go", 28 28 } 29 29 30 - provider = github.NewProvider(token, cfg, cacheClient) 30 + p := github.NewProvider(token, cfg, cacheClient) 31 + p.GithubSearchClient = larrySearchFix{inner: p.GithubSearchClient} 32 + provider = p 31 33 return nil 32 34 } 33 35
+27
internal/content/larry_fix.go
··· 1 + package content 2 + 3 + import ( 4 + "context" 5 + "strings" 6 + 7 + gh "github.com/google/go-github/v39/github" 8 + ) 9 + 10 + // larrySearchFix wraps larry's GitHub search client to repair a query-encoding 11 + // bug in upstream (which is unmaintained). 12 + // 13 + // larry joins qualifiers with literal '+' characters (e.g. "a+language:go"). 14 + // go-github URL-encodes those as %2B, so GitHub receives a single fuzzy text 15 + // term and silently drops the language qualifier — returning repos in any language. 16 + // 17 + // Spaces, which go-github encodes as '+' on the wire, are the actual GitHub search 18 + // separator. 19 + type larrySearchFix struct { 20 + inner interface { 21 + Repositories(ctx context.Context, query string, opt *gh.SearchOptions) (*gh.RepositoriesSearchResult, *gh.Response, error) 22 + } 23 + } 24 + 25 + func (f larrySearchFix) Repositories(ctx context.Context, query string, opt *gh.SearchOptions) (*gh.RepositoriesSearchResult, *gh.Response, error) { 26 + return f.inner.Repositories(ctx, strings.ReplaceAll(query, "+", " "), opt) 27 + }