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.
This commit is contained in:
Julian Tölle 2024-09-06 23:27:48 +02:00 committed by GitHub
parent 2effe5e72d
commit b9dd0f986c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View file

@ -13,6 +13,7 @@ type Forge interface {
RepoURL() string RepoURL() string
CloneURL() string CloneURL() string
ReleaseURL(version string) string ReleaseURL(version string) string
PullRequestURL(id int) string
GitAuth() transport.AuthMethod GitAuth() transport.AuthMethod

View file

@ -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) 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 { func (g *GitHub) GitAuth() transport.AuthMethod {
return &http.BasicAuth{ return &http.BasicAuth{
Username: g.options.Username, Username: g.options.Username,

View file

@ -300,7 +300,7 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
if err != nil { if err != nil {
return err 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 { } else {
pr.SetTitle(rp.targetBranch, nextVersion) pr.SetTitle(rp.targetBranch, nextVersion)
@ -317,7 +317,7 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
if err != nil { if err != nil {
return err 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 return nil