From 3a35c5353ecbb43429474a7db3dcfa23df550279 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 8 May 2026 04:46:57 +0200 Subject: [PATCH] feat: expose AGit topic branch in API PR head label (#12352) For Agit-flow pull requests, `head.label` was explicitly set to an empty string. The head branch name (which contains the Agit topic, e.g. `user2/my-topic`) was already populated from `pr.HeadBranch` but then discarded. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12352 Reviewed-by: Gusted Reviewed-by: Cyborus --- services/convert/pull.go | 1 - tests/integration/git_test.go | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/convert/pull.go b/services/convert/pull.go index 41cbcc25aa..4856c58736 100644 --- a/services/convert/pull.go +++ b/services/convert/pull.go @@ -177,7 +177,6 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u } apiPullRequest.Head.RepoID = pr.BaseRepoID apiPullRequest.Head.Repository = apiPullRequest.Base.Repository - apiPullRequest.Head.Name = "" } if pr.HeadRepo != nil && pr.Flow == issues_model.PullRequestFlowGithub { diff --git a/tests/integration/git_test.go b/tests/integration/git_test.go index 954a0fd359..83853883c1 100644 --- a/tests/integration/git_test.go +++ b/tests/integration/git_test.go @@ -860,6 +860,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, headBranch string assert.False(t, prMsg.HasMerged) assert.Contains(t, "Testing commit 1", prMsg.Body) assert.Equal(t, commit, prMsg.Head.Sha) + assert.Equal(t, "user2/"+headBranch, prMsg.Head.Name) _, _, err = git.NewCommand(git.DefaultContext, "push", "origin").AddDynamicArguments("HEAD:refs/for/master/test/" + headBranch).RunStdString(&git.RunOpts{Dir: dstPath}) require.NoError(t, err) @@ -878,6 +879,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, headBranch string prMsg = doAPIGetPullRequest(*ctx, ctx.Username, ctx.Reponame, pr2.Index)(t) assert.Equal(t, "user2/test/"+headBranch, pr2.HeadBranch) + assert.Equal(t, "user2/test/"+headBranch, prMsg.Head.Name) assert.False(t, prMsg.HasMerged) })