From 67bb0e77896b56b7df4c742c863a0261ccf61bbe Mon Sep 17 00:00:00 2001 From: LeonM <206012+leonm@noreply.gitea.com> Date: Mon, 15 Jun 2026 20:35:21 +0000 Subject: [PATCH] feat(pulls): show PR URL in detail view (#1036) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1035. ## Summary - include the pull request URL in `tea pr ` detail output - keep `tea pr create` output to one URL by relying on the shared detail renderer - add a focused regression test ## Tests - `go test ./modules/print` - `go test ./...` --------- Co-authored-by: Lunny Xiao Co-authored-by: Leon Müller Reviewed-on: https://gitea.com/gitea/tea/pulls/1036 Reviewed-by: Lunny Xiao Co-authored-by: LeonM <206012+leonm@noreply.gitea.com> Co-committed-by: LeonM <206012+leonm@noreply.gitea.com> --- modules/print/pull.go | 4 ++++ modules/print/pull_test.go | 11 +++++++++++ modules/task/pull_create.go | 2 -- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/print/pull.go b/modules/print/pull.go index 1be458f3..fcdf9781 100644 --- a/modules/print/pull.go +++ b/modules/print/pull.go @@ -73,6 +73,10 @@ func PullDetails(pr *gitea.PullRequest, reviews []*gitea.PullReview, ciStatus *g out += "- Maintainers are allowed to edit\n" } + if pr.HTMLURL != "" { + out = strings.TrimRight(out, "\n") + "\n\n" + pr.HTMLURL + "\n" + } + outputMarkdown(out, getRepoURL(pr.HTMLURL)) } diff --git a/modules/print/pull_test.go b/modules/print/pull_test.go index d771ff82..39db8bd7 100644 --- a/modules/print/pull_test.go +++ b/modules/print/pull_test.go @@ -99,6 +99,17 @@ func TestFormatCIStatusAllStates(t *testing.T) { } } +func TestPullDetailsIncludesHTMLURL(t *testing.T) { + pr := newTestPR(8, "Crm wip") + pr.HTMLURL = "https://gitea.example.com/owner/repo/pulls/8" + + out := captureStdout(t, func() { + PullDetails(pr, nil, nil) + }) + + assert.Contains(t, out, pr.HTMLURL) +} + func TestPullsListWithCIField(t *testing.T) { prs := []*gitea.PullRequest{ newTestPR(1, "feat: add feature"), diff --git a/modules/task/pull_create.go b/modules/task/pull_create.go index 9bd2f597..f35f5783 100644 --- a/modules/task/pull_create.go +++ b/modules/task/pull_create.go @@ -88,8 +88,6 @@ func CreatePull(requestCtx stdctx.Context, ctx *context.TeaContext, base, head s print.PullDetails(pr, nil, nil) - fmt.Println(pr.HTMLURL) - return err }