Select the types of activity you want to include in your feed.
all: gofumpt -l -w .
gofumpt is a stricter gofmt. I took a look at the changes and in general they are nice. I don't think we need to enforce the use of gofumpt, but I like the idea of running it every once in a while.
···902902// trigger an initial merge run. In the steady-state, merges happen rarely, even
903903// on busy instances, and users can rely on automatic merging instead.
904904func (s *Server) handleDebugMerge(w http.ResponseWriter, _ *http.Request) {
905905-906905 // A merge operation can take very long, depending on the number merges and the
907906 // target size of the compound shards. We run the merge in the background and
908907 // return immediately to the user.
···10271026 }
10281027 }
1029102810301030- if err := os.MkdirAll(tmpRoot, 0755); err != nil {
10291029+ if err := os.MkdirAll(tmpRoot, 0o755); err != nil {
10311030 return err
10321031 }
10331032···12751274 go func() {
12761275 debug.Printf("serving HTTP on %s", conf.listen)
12771276 log.Fatal(http.ListenAndServe(conf.listen, mux))
12781278-12791277 }()
1280127812811279 // Serve mux on a unix domain socket on a best-effort-basis so that
···13031301 // it.
13041302 //
13051303 // See https://github.com/golang/go/issues/11822 for more context.
13061306- if err := os.Chmod(socket, 0777); err != nil {
13041304+ if err := os.Chmod(socket, 0o777); err != nil {
13071305 return fmt.Errorf("failed to change permission of socket %s: %w", socket, err)
13081306 }
13091307 debug.Printf("serving HTTP on %s", socket)
···13621360 }
1363136113641362 if _, err := os.Stat(conf.index); err != nil {
13651365- if err := os.MkdirAll(conf.index, 0755); err != nil {
13631363+ if err := os.MkdirAll(conf.index, 0o755); err != nil {
13661364 return nil, fmt.Errorf("MkdirAll %s: %v", conf.index, err)
13671365 }
13681366 }
-2
cmd/zoekt-sourcegraph-indexserver/main_test.go
···134134135135func TestListRepoIDs(t *testing.T) {
136136 t.Run("gRPC", func(t *testing.T) {
137137-138137 grpcClient := &mockGRPCClient{}
139138140139 clientOptions := []SourcegraphClientOption{
···247246248247 msg := "deadbeaf deadbeaf"
249248 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
250250-251249 // This is how Sourcegraph returns error messages to the caller.
252250 http.Error(w, msg, http.StatusInternalServerError)
253251 }))
-1
cmd/zoekt-sourcegraph-indexserver/merge.go
···57575858// same as doMerge but with a configurable merge command.
5959func (s *Server) merge(mergeCmd func(args ...string) *exec.Cmd) {
6060-6160 // Guard against the user triggering competing merge jobs with the debug
6261 // command.
6362 if !mergeRunning.CompareAndSwap(false, true) {
-2
cmd/zoekt-sourcegraph-indexserver/merge_test.go
···118118}
119119120120func TestMerge(t *testing.T) {
121121-122121 // A fixed set of shards gives us reliable shard sizes which makes it easy to
123122 // define a cutoff with targetSizeBytes.
124123 m := []string{
···197196 checkCount(dir, "*_v16.00000.zoekt", tc.wantSimple)
198197 })
199198 }
200200-201199}
202200203201func copyTestShards(dstDir string, srcShards []string) ([]string, error) {
+1-1
cmd/zoekt-sourcegraph-indexserver/owner.go
···6767`, o.Hostname))
68686969 // Always write out since we may update the comment
7070- if err := os.WriteFile(o.Path, content, 0600); err != nil {
7070+ if err := os.WriteFile(o.Path, content, 0o600); err != nil {
7171 return fmt.Errorf("failed to write owner file %s: %w", o.Path, err)
7272 }
7373
+1-1
cmd/zoekt-sourcegraph-indexserver/owner_test.go
···3838 assertSuccess(bob.Check()) // bob is still the owner
39394040 // Test what happens if someone corrupts the file
4141- if err := os.WriteFile(path, []byte("!corrupt"), 0600); err != nil {
4141+ if err := os.WriteFile(path, []byte("!corrupt"), 0o600); err != nil {
4242 t.Fatal(err)
4343 }
4444 assertFailed(alice.Check()) // corrupt so fail
-1
cmd/zoekt-sourcegraph-indexserver/queue_test.go
···129129}
130130131131func TestQueue_Integration_DebugQueue(t *testing.T) {
132132-133132 // helper function to normalize the queue's debug output - this makes the test less brittle
134133 // + makes it much less annoying to make edits to the expected output in a way that doesn't
135134 // materially affect the caller
-3
cmd/zoekt-sourcegraph-indexserver/sg.go
···141141 }
142142143143 return client
144144-145144}
146145147146// sourcegraphClient contains methods which interact with the sourcegraph API.
···763762func (s *sourcegraphClient) updateIndexStatusGRPC(r updateIndexStatusRequest) error {
764763 request := r.ToProto()
765764 _, err := s.grpcClient.UpdateIndexStatus(context.Background(), request)
766766-767765 if err != nil {
768766 return fmt.Errorf("failed to update index status: %w", err)
769767 }
···924922 items[idx] = indexOptionsItem{IndexOptions: opts}
925923 }
926924 })
927927-928925 if err != nil {
929926 return nil, err
930927 }
+4-2
cmd/zoekt-test/main.go
···169169 return nil
170170}
171171172172-var memprofile = flag.String("memprofile", "", "write memory profile to `file`")
173173-var cpuprofile = flag.String("cpuprofile", "", "write memory profile to `file`")
172172+var (
173173+ memprofile = flag.String("memprofile", "", "write memory profile to `file`")
174174+ cpuprofile = flag.String("cpuprofile", "", "write memory profile to `file`")
175175+)
174176175177func testLoadIndexDir(indexDir string) {
176178 var a, b runtime.MemStats
-2
cmd/zoekt-webserver/grpc/server/server_test.go
···129129 if diff := cmp.Diff(expectedResult.GetProgress(), receivedResponse.GetProgress(), protocmp.Transform()); diff != "" {
130130 return fmt.Errorf("unexpected difference in progress (-want +got):\n%s", diff)
131131 }
132132-133132 } else {
134133 // All other responses should ensure that the progress' priority is less than the max-pending priority, to
135134 // ensure that the client consumes the entire set of chunks
···140139 i, receivedResponse,
141140 receivedResponse.GetProgress().GetPriority(), receivedResponse.GetProgress().GetMaxPendingPriority(),
142141 )
143143-144142 }
145143 }
146144
···1212 "github.com/sourcegraph/zoekt/stream"
1313)
14141515-var (
1616- metricFinalAggregateSize = promauto.NewHistogramVec(prometheus.HistogramOpts{
1717- Name: "zoekt_final_aggregate_size",
1818- Help: "The number of file matches we aggregated before flushing",
1919- Buckets: prometheus.ExponentialBuckets(1, 2, 20),
2020- }, []string{"reason"})
2121-)
1515+var metricFinalAggregateSize = promauto.NewHistogramVec(prometheus.HistogramOpts{
1616+ Name: "zoekt_final_aggregate_size",
1717+ Help: "The number of file matches we aggregated before flushing",
1818+ Buckets: prometheus.ExponentialBuckets(1, 2, 20),
1919+}, []string{"reason"})
22202321// collectSender is a sender that will aggregate results. Once sending is
2422// done, you call Done to return the aggregated result which are ranked.
-1
shards/shards.go
···770770// We split by repository instead of by priority because it is easier to set
771771// RepoURLs and LineFragments in zoekt.SearchResult.
772772func sendByRepository(result *zoekt.SearchResult, opts *zoekt.SearchOptions, sender zoekt.Sender) {
773773-774773 if len(result.RepoURLs) <= 1 || len(result.Files) == 0 {
775774 zoekt.SortFiles(result.Files)
776775 sender.Send(result)
-2
shards/shards_test.go
···261261 stream.SenderFunc(func(event *zoekt.SearchResult) {
262262 results = append(results, event)
263263 }))
264264-265264 if err != nil {
266265 t.Fatal(err)
267266 }
···863862 // n1, n2, n3 are the number of file matches for each of the 3 repositories in this
864863 // test.
865864 f := func(n1, n2, n3 uint8) bool {
866866-867865 sr := createMockSearchResult(n1, n2, n3, wantStats)
868866869867 mock := &mockSender{}