diff --git a/server/forge/bitbucket/convert.go b/server/forge/bitbucket/convert.go index ab8f9578fa..e4e3856501 100644 --- a/server/forge/bitbucket/convert.go +++ b/server/forge/bitbucket/convert.go @@ -171,7 +171,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { pipeline := &model.Pipeline{ Event: event, Commit: from.PullRequest.Source.Commit.Hash, - Ref: fmt.Sprintf("refs/heads/%s", from.PullRequest.Source.Branch.Name), + Ref: fmt.Sprintf("refs/pull-requests/%d/from", from.PullRequest.ID), Refspec: fmt.Sprintf("%s:%s", from.PullRequest.Source.Branch.Name, from.PullRequest.Dest.Branch.Name, diff --git a/server/forge/bitbucket/convert_test.go b/server/forge/bitbucket/convert_test.go index b1adad9299..70dac2bae9 100644 --- a/server/forge/bitbucket/convert_test.go +++ b/server/forge/bitbucket/convert_test.go @@ -133,6 +133,7 @@ func Test_helper(t *testing.T) { hook.PullRequest.Links.HTML.Href = "https://bitbucket.org/foo/bar/pulls/5" hook.PullRequest.Title = "updated README" hook.PullRequest.Updated = time.Now() + hook.PullRequest.ID = 1 pipeline := convertPullHook(hook) g.Assert(pipeline.Event).Equal(model.EventPull) @@ -141,7 +142,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Commit).Equal(hook.PullRequest.Source.Commit.Hash) g.Assert(pipeline.Branch).Equal(hook.PullRequest.Source.Branch.Name) g.Assert(pipeline.ForgeURL).Equal(hook.PullRequest.Links.HTML.Href) - g.Assert(pipeline.Ref).Equal("refs/heads/change") + g.Assert(pipeline.Ref).Equal("refs/pull-requests/1/from") g.Assert(pipeline.Refspec).Equal("change:main") g.Assert(pipeline.Message).Equal(hook.PullRequest.Title) g.Assert(pipeline.Timestamp).Equal(hook.PullRequest.Updated.Unix())