Skip to content

Commit

Permalink
feat: format pull request link (#181)
Browse files Browse the repository at this point in the history
* feat: format pull request link

* feat: format pull request link
  • Loading branch information
ryan-timothy-albert authored Oct 30, 2024
1 parent b052520 commit ffc355c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func Track(ctx context.Context, exec shared.InteractionType, fn func(ctx context
err = fn(ctx, runEvent)

// Populate event with pull request env var (available only after run)
ghPullRequest := os.Getenv("GH_PULL_REQUEST")
ghPullRequest := reformatPullRequestURL(os.Getenv("GH_PULL_REQUEST"))

if ghPullRequest != "" {
runEvent.GhPullRequest = &ghPullRequest
Expand Down Expand Up @@ -153,3 +153,9 @@ func Track(ctx context.Context, exec shared.InteractionType, fn func(ctx context
return err

}

// Reformat from https://api.github.com/repos/.../.../pulls/... to https://github.com/.../.../pull/...
func reformatPullRequestURL(url string) string {
url = strings.Replace(url, "https://api.github.com/repos/", "https://github.com/", 1)
return strings.Replace(url, "/pulls/", "/pull/", 1)
}

0 comments on commit ffc355c

Please sign in to comment.