From fbc6eadd3214922dd791df0d3047190cb83a1ac4 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sat, 19 Nov 2016 23:44:22 +0100 Subject: [PATCH] bitbucket refspec and remote url --- remote/bitbucket/convert.go | 12 ++++++++---- remote/bitbucket/convert_test.go | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/remote/bitbucket/convert.go b/remote/bitbucket/convert.go index b64863cd1..6963a3e21 100644 --- a/remote/bitbucket/convert.go +++ b/remote/bitbucket/convert.go @@ -149,10 +149,14 @@ func convertTeam(from *internal.Account) *model.Team { // hook to the Drone build struct holding commit information. func convertPullHook(from *internal.PullRequestHook) *model.Build { return &model.Build{ - Event: model.EventPull, - Commit: from.PullRequest.Dest.Commit.Hash, - Ref: fmt.Sprintf("refs/heads/%s", from.PullRequest.Dest.Branch.Name), - Remote: cloneLink(&from.PullRequest.Dest.Repo), + Event: model.EventPull, + Commit: from.PullRequest.Dest.Commit.Hash, + Ref: fmt.Sprintf("refs/heads/%s", from.PullRequest.Dest.Branch.Name), + Refspec: fmt.Sprintf("%s:%s", + from.PullRequest.Source.Branch.Name, + from.PullRequest.Dest.Branch.Name, + ), + Remote: fmt.Sprintf("https://bitbucket.org/%s", from.PullRequest.Source.Repo.FullName), Link: from.PullRequest.Links.Html.Href, Branch: from.PullRequest.Dest.Branch.Name, Message: from.PullRequest.Desc, diff --git a/remote/bitbucket/convert_test.go b/remote/bitbucket/convert_test.go index 0baf30c4c..2a91041ba 100644 --- a/remote/bitbucket/convert_test.go +++ b/remote/bitbucket/convert_test.go @@ -139,6 +139,8 @@ func Test_helper(t *testing.T) { hook.PullRequest.Dest.Commit.Hash = "73f9c44d" hook.PullRequest.Dest.Branch.Name = "master" hook.PullRequest.Dest.Repo.Links.Html.Href = "https://bitbucket.org/foo/bar" + hook.PullRequest.Source.Branch.Name = "change" + hook.PullRequest.Source.Repo.FullName = "baz/bar" hook.PullRequest.Links.Html.Href = "https://bitbucket.org/foo/bar/pulls/5" hook.PullRequest.Desc = "updated README" hook.PullRequest.Updated = time.Now() @@ -151,6 +153,8 @@ func Test_helper(t *testing.T) { g.Assert(build.Branch).Equal(hook.PullRequest.Dest.Branch.Name) g.Assert(build.Link).Equal(hook.PullRequest.Links.Html.Href) g.Assert(build.Ref).Equal("refs/heads/master") + g.Assert(build.Refspec).Equal("change:master") + g.Assert(build.Remote).Equal("https://bitbucket.org/baz/bar") g.Assert(build.Message).Equal(hook.PullRequest.Desc) g.Assert(build.Timestamp).Equal(hook.PullRequest.Updated.Unix()) })