1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

rm workaround for gitlab webhook parsing (#601)

upstream got merged: https://github.com/xanzy/go-gitlab/pull/1282
possible because of #599
This commit is contained in:
6543 2021-12-12 21:40:36 +01:00 committed by GitHub
parent 70fcc173b9
commit 0e89923854
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,6 @@ package gitlab
import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net"
@ -467,26 +466,7 @@ func (g *Gitlab) Hook(req *http.Request) (*model.Repo, *model.Build, error) {
return nil, nil, err
}
eventType := gitlab.WebhookEventType(req)
// TODO: Fix Upstream: We get `Service Hook` - which the library do not understand
if eventType == "Service Hook" {
e := struct {
ObjectKind string `json:"object_kind"`
}{}
if err := json.Unmarshal(payload, &e); err != nil {
return nil, nil, err
}
switch e.ObjectKind {
case "push":
eventType = gitlab.EventTypePush
case "tag_push":
eventType = gitlab.EventTypeTagPush
case "merge_request":
eventType = gitlab.EventTypeMergeRequest
}
}
parsed, err := gitlab.ParseWebhook(eventType, payload)
parsed, err := gitlab.ParseWebhook(gitlab.WebhookEventType(req), payload)
if err != nil {
return nil, nil, err
}