Fix BB PR pipeline ref (#3985)

This commit is contained in:
Joan Flotats 2024-08-02 21:42:04 +02:00 committed by GitHub
parent 6f4ef6d18d
commit 2d6e1ea015
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -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,

View file

@ -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())