gitsources: don't set branch value when in a pull request

We were passing the source branch name as the Branch value in the webhook data.

This patch will just delete this assignment. If in future it's needed let's add
it with a different name to not cause confusion.
This commit is contained in:
Simone Gotti 2019-10-14 17:20:20 +02:00
parent 9c2b9a7d7e
commit 3d0c68b5fc
3 changed files with 5 additions and 15 deletions

View File

@ -162,7 +162,6 @@ func webhookDataFromPullRequest(hook *pullRequestHook) *types.WebhookData {
SSHURL: hook.Repo.SSHURL,
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
CommitLink: fmt.Sprintf("%s/commit/%s", hook.Repo.URL, hook.PullRequest.Head.Sha),
Branch: hook.PullRequest.Base.Ref,
Message: hook.PullRequest.Title,
Sender: sender,
PullRequestID: strconv.FormatInt(hook.PullRequest.ID, 10),

View File

@ -123,7 +123,6 @@ func webhookDataFromPullRequest(hook *github.PullRequestEvent) (*types.WebhookDa
SSHURL: *hook.Repo.SSHURL,
Ref: fmt.Sprintf("refs/pull/%d/head", *hook.Number),
CommitLink: fmt.Sprintf("%s/commit/%s", *hook.Repo.HTMLURL, *hook.PullRequest.Head.SHA),
Branch: *hook.PullRequest.Base.Ref,
Message: *hook.PullRequest.Title,
Sender: *sender,
PullRequestID: strconv.Itoa(*hook.PullRequest.Number),

View File

@ -104,9 +104,7 @@ func webhookDataFromPush(hook *pushHook) (*types.WebhookData, error) {
SSHURL: hook.Project.SSHURL,
Ref: hook.Ref,
CommitLink: hook.Commits[0].URL,
//CompareLink: hook.Compare,
//CommitLink: fmt.Sprintf("%s/commit/%s", hook.Repo.URL, hook.After),
Sender: sender,
Sender: sender,
Repo: types.WebhookDataRepo{
Path: hook.Project.PathWithNamespace,
@ -142,18 +140,12 @@ func webhookDataFromPullRequest(hook *pullRequestHook) *types.WebhookData {
if sender == "" {
sender = hook.User.Username
}
//sender := hook.ObjectAttributes.LastCommit.Author.Name
//if sender == "" {
// sender := hook.ObjectAttributes.LastCommit.Author.UserName
//}
build := &types.WebhookData{
Event: types.WebhookEventPullRequest,
CommitSHA: hook.ObjectAttributes.LastCommit.ID,
SSHURL: hook.Project.SSHURL,
Ref: fmt.Sprintf("refs/merge-requests/%d/head", hook.ObjectAttributes.Iid),
//CommitLink: fmt.Sprintf("%s/commit/%s", hook.Repo.URL, hook.PullRequest.Head.Sha),
Event: types.WebhookEventPullRequest,
CommitSHA: hook.ObjectAttributes.LastCommit.ID,
SSHURL: hook.Project.SSHURL,
Ref: fmt.Sprintf("refs/merge-requests/%d/head", hook.ObjectAttributes.Iid),
CommitLink: hook.ObjectAttributes.LastCommit.URL,
Branch: hook.ObjectAttributes.SourceBranch,
Message: hook.ObjectAttributes.Title,
Sender: sender,
PullRequestID: strconv.Itoa(hook.ObjectAttributes.Iid),