Skip to content

Commit

Permalink
Add Bitbucket fixes to Release/2.8 (#4547)
Browse files Browse the repository at this point in the history
Co-authored-by: Joan Flotats <joanflotats@bit2me.com>
  • Loading branch information
j04n-f and Joan Flotats authored Dec 10, 2024
1 parent 21d9c6c commit 36e5b95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions server/forge/bitbucket/bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ func (c *config) Dir(ctx context.Context, u *model.User, r *model.Repo, p *model
}

// Status creates a pipeline status for the Bitbucket commit.
func (c *config) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, _ *model.Workflow) error {
func (c *config) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, workflow *model.Workflow) error {
status := internal.PipelineStatus{
State: convertStatus(pipeline.Status),
Desc: common.GetPipelineStatusDescription(pipeline.Status),
Key: "Woodpecker",
Key: common.GetPipelineStatusContext(repo, pipeline, workflow),
URL: common.GetPipelineStatusURL(repo, pipeline, nil),
}
return c.newClient(ctx, user).CreateStatus(repo.Owner, repo.Name, pipeline.Commit, &status)
Expand Down
4 changes: 2 additions & 2 deletions server/forge/bitbucket/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ 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,
),
ForgeURL: from.PullRequest.Links.HTML.Href,
Branch: from.PullRequest.Source.Branch.Name,
Message: from.PullRequest.Desc,
Message: from.PullRequest.Title,
Avatar: from.Actor.Links.Avatar.Href,
Author: from.Actor.Login,
Sender: from.Actor.Login,
Expand Down
7 changes: 4 additions & 3 deletions server/forge/bitbucket/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ func Test_helper(t *testing.T) {
hook.PullRequest.Source.Repo.FullName = "baz/bar"
hook.PullRequest.Source.Commit.Hash = "c8411d7"
hook.PullRequest.Links.HTML.Href = "https://bitbucket.org/foo/bar/pulls/5"
hook.PullRequest.Desc = "updated README"
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,9 +142,9 @@ 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.Desc)
g.Assert(pipeline.Message).Equal(hook.PullRequest.Title)
g.Assert(pipeline.Timestamp).Equal(hook.PullRequest.Updated.Unix())
})

Expand Down

0 comments on commit 36e5b95

Please sign in to comment.