Skip to content

Commit

Permalink
Fix BB PR pipeline ref (#3985)
Browse files Browse the repository at this point in the history
  • Loading branch information
j04n-f authored Aug 2, 2024
1 parent 6f4ef6d commit 2d6e1ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/forge/bitbucket/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion server/forge/bitbucket/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand Down

0 comments on commit 2d6e1ea

Please sign in to comment.