From 2465728633d64e767834629eb0de5c02af537ac8 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sat, 19 Nov 2016 22:54:05 +0100 Subject: [PATCH] track github remote url --- remote/github/convert.go | 1 + remote/github/convert_test.go | 2 ++ remote/github/types.go | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/remote/github/convert.go b/remote/github/convert.go index 45db4078b..950ff1fff 100644 --- a/remote/github/convert.go +++ b/remote/github/convert.go @@ -230,6 +230,7 @@ func convertPullHook(from *webhook, merge bool) *model.Build { Author: from.PullRequest.User.Login, Avatar: from.PullRequest.User.Avatar, Title: from.PullRequest.Title, + Remote: from.PullRequest.Head.Repo.CloneURL, Refspec: fmt.Sprintf(refspec, from.PullRequest.Head.Ref, from.PullRequest.Base.Ref, diff --git a/remote/github/convert_test.go b/remote/github/convert_test.go index 9c67c09c5..711bd4417 100644 --- a/remote/github/convert_test.go +++ b/remote/github/convert_test.go @@ -175,6 +175,7 @@ func Test_helper(t *testing.T) { from.PullRequest.Base.Ref = "master" from.PullRequest.Head.Ref = "changes" from.PullRequest.Head.SHA = "f72fc19" + from.PullRequest.Head.Repo.CloneURL = "https://github.com/octocat/hello-world-fork" from.PullRequest.HTMLURL = "https://github.com/octocat/hello-world/pulls/42" from.PullRequest.Number = 42 from.PullRequest.Title = "Updated README.md" @@ -186,6 +187,7 @@ func Test_helper(t *testing.T) { g.Assert(build.Branch).Equal(from.PullRequest.Head.Ref) g.Assert(build.Ref).Equal("refs/pull/42/merge") g.Assert(build.Refspec).Equal("changes:master") + g.Assert(build.Remote).Equal("https://github.com/octocat/hello-world-fork") g.Assert(build.Commit).Equal(from.PullRequest.Head.SHA) g.Assert(build.Message).Equal(from.PullRequest.Title) g.Assert(build.Title).Equal(from.PullRequest.Title) diff --git a/remote/github/types.go b/remote/github/types.go index 6285cdc41..63f3a3573 100644 --- a/remote/github/types.go +++ b/remote/github/types.go @@ -73,8 +73,11 @@ type webhook struct { } `json:"base"` Head struct { - SHA string `json:"sha"` - Ref string `json:"ref"` + SHA string `json:"sha"` + Ref string `json:"ref"` + Repo struct { + CloneURL string `json:"clone_url"` + } `json:"repo"` } `json:"head"` } `json:"pull_request"` }