Skip to content

Commit

Permalink
gopls/internal/telemetry/cmd/stacks: add dry run flag
Browse files Browse the repository at this point in the history
This flag avoids updating existing issues. It still requires a GitHub
auth token to determine which issues would get updated. It also still
opens a browser window for new issues.

For golang/go#71045.

Change-Id: I6a6a636c26a402c9ea66160e14cd388b490b74b9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/642421
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
prattmic authored and gopherbot committed Jan 22, 2025
1 parent 38d0631 commit 9f4a509
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gopls/internal/telemetry/cmd/stacks/stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ var (

daysFlag = flag.Int("days", 7, "number of previous days of telemetry data to read")

dryRun = flag.Bool("n", false, "dry run, avoid updating issues")

authToken string // mandatory GitHub authentication token (for R/W issues access)
)

Expand Down Expand Up @@ -559,6 +561,12 @@ func updateIssues(issues []*Issue, stacks map[string]map[Info]int64, stackToURL
newStackIDs = append(newStackIDs, id)
writeStackComment(comment, stack, id, stackToURL[stack], stacks[stack])
}

if *dryRun {
log.Printf("DRY RUN: would add stacks %s to issue #%d", newStackIDs, issue.Number)
continue
}

if err := addIssueComment(issue.Number, comment.String()); err != nil {
log.Println(err)
continue
Expand Down

0 comments on commit 9f4a509

Please sign in to comment.