Skip to content

Commit

Permalink
feat(cli): show release PR url in log messages (#44)
Browse files Browse the repository at this point in the history
Makes navigating to the PR way easier when looking at the logs.

This requires a new `Forge.PullRequestURL()` method that needs to be
implemented for all forges.
  • Loading branch information
apricote authored Sep 6, 2024
1 parent 2effe5e commit b9dd0f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/forge/forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Forge interface {
RepoURL() string
CloneURL() string
ReleaseURL(version string) string
PullRequestURL(id int) string

GitAuth() transport.AuthMethod

Expand Down
4 changes: 4 additions & 0 deletions internal/forge/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (g *GitHub) ReleaseURL(version string) string {
return fmt.Sprintf("https://github.com/%s/%s/releases/tag/%s", g.options.Owner, g.options.Repo, version)
}

func (g *GitHub) PullRequestURL(id int) string {
return fmt.Sprintf("https://github.com/%s/%s/pull/%d", g.options.Owner, g.options.Repo, id)
}

func (g *GitHub) GitAuth() transport.AuthMethod {
return &http.BasicAuth{
Username: g.options.Username,
Expand Down
4 changes: 2 additions & 2 deletions releaserpleaser.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
if err != nil {
return err
}
logger.InfoContext(ctx, "opened pull request", "pr.title", pr.Title, "pr.id", pr.ID)
logger.InfoContext(ctx, "opened pull request", "pr.title", pr.Title, "pr.id", pr.ID, "pr.url", rp.forge.PullRequestURL(pr.ID))
} else {
pr.SetTitle(rp.targetBranch, nextVersion)

Expand All @@ -317,7 +317,7 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
if err != nil {
return err
}
logger.InfoContext(ctx, "updated pull request", "pr.title", pr.Title, "pr.id", pr.ID)
logger.InfoContext(ctx, "updated pull request", "pr.title", pr.Title, "pr.id", pr.ID, "pr.url", rp.forge.PullRequestURL(pr.ID))
}

return nil
Expand Down

0 comments on commit b9dd0f9

Please sign in to comment.