21
21
// single ID in the issue body suffices to record the
22
22
// association. But most problems are exhibited in a variety of
23
23
// ways, leading to multiple field reports of similar but
24
- // distinct stacks.
24
+ // distinct stacks. Hence the following way to associate stacks
25
+ // with issues.
25
26
//
26
27
// 2. Each GitHub issue body may start with a code block of this form:
27
28
//
@@ -302,6 +303,7 @@ func (info Info) String() string {
302
303
//
303
304
// stacks is a map of stack text to program metadata to stack+metadata report
304
305
// count.
306
+ // TODO(jba): fix distinctStacks doc? It seems to be the number of telemetry.ProgramReports, not the number of stacks.
305
307
// distinctStacks is the sum of all counts in stacks.
306
308
// stackToURL maps the stack text to the oldest telemetry JSON report it was
307
309
// included in.
@@ -339,14 +341,19 @@ func readReports(pcfg ProgramConfig, days int) (stacks map[string]map[Info]int64
339
341
if len (prog .Stacks ) == 0 {
340
342
continue
341
343
}
344
+ // Ignore @devel versions as they correspond to
345
+ // ephemeral (and often numerous) variations of
346
+ // the program as we work on a fix to a bug.
347
+ if prog .Version == "devel" {
348
+ continue
349
+ }
342
350
343
351
// Include applicable client names (e.g. vscode, eglot) for gopls.
344
352
var clientSuffix string
345
353
if pcfg .IncludeClient {
346
354
var clients []string
347
355
for key := range prog .Counters {
348
- client := strings .TrimPrefix (key , "gopls/client:" )
349
- if client != key {
356
+ if client , ok := strings .CutPrefix (key , "gopls/client:" ); ok {
350
357
clients = append (clients , client )
351
358
}
352
359
}
@@ -356,13 +363,6 @@ func readReports(pcfg ProgramConfig, days int) (stacks map[string]map[Info]int64
356
363
}
357
364
}
358
365
359
- // Ignore @devel versions as they correspond to
360
- // ephemeral (and often numerous) variations of
361
- // the program as we work on a fix to a bug.
362
- if prog .Version == "devel" {
363
- continue
364
- }
365
-
366
366
distinctStacks ++
367
367
368
368
info := Info {
@@ -395,6 +395,7 @@ func readIssues(pcfg ProgramConfig) ([]*Issue, error) {
395
395
// Query GitHub for all existing GitHub issues with the report label.
396
396
issues , err := searchIssues (pcfg .SearchLabel )
397
397
if err != nil {
398
+ // TODO(jba): return error instead of dying, or doc.
398
399
log .Fatalf ("GitHub issues label %q search failed: %v" , pcfg .SearchLabel , err )
399
400
}
400
401
@@ -496,20 +497,6 @@ func readIssues(pcfg ProgramConfig) ([]*Issue, error) {
496
497
// We log an error if two different issues attempt to claim
497
498
// the same stack.
498
499
func claimStacks (issues []* Issue , stacks map [string ]map [Info ]int64 ) map [string ]* Issue {
499
- // Map each stack ID to its issue.
500
- //
501
- // An issue can claim a stack two ways:
502
- //
503
- // 1. if the issue body contains the ID of the stack. Matching
504
- // is a little loose but base64 will rarely produce words
505
- // that appear in the body by chance.
506
- //
507
- // 2. if the issue body contains a ```#!stacks``` predicate
508
- // that matches the stack.
509
- //
510
- // We report an error if two different issues attempt to claim
511
- // the same stack.
512
- //
513
500
// This is O(new stacks x existing issues).
514
501
claimedBy := make (map [string ]* Issue )
515
502
for stack := range stacks {
0 commit comments