From b9dd0f986ce5d56a39b5d29332b3bec631093c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Fri, 6 Sep 2024 23:27:48 +0200 Subject: [PATCH] feat(cli): show release PR url in log messages (#44) 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. --- internal/forge/forge.go | 1 + internal/forge/github/github.go | 4 ++++ releaserpleaser.go | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/forge/forge.go b/internal/forge/forge.go index a5f418d..0bd119a 100644 --- a/internal/forge/forge.go +++ b/internal/forge/forge.go @@ -13,6 +13,7 @@ type Forge interface { RepoURL() string CloneURL() string ReleaseURL(version string) string + PullRequestURL(id int) string GitAuth() transport.AuthMethod diff --git a/internal/forge/github/github.go b/internal/forge/github/github.go index e7f6f97..d96fc9d 100644 --- a/internal/forge/github/github.go +++ b/internal/forge/github/github.go @@ -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, diff --git a/releaserpleaser.go b/releaserpleaser.go index a846c16..a69ef9e 100644 --- a/releaserpleaser.go +++ b/releaserpleaser.go @@ -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) @@ -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