mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-04 10:04:39 +00:00
@@ -17,6 +17,7 @@ package gitea
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/model"
|
"github.com/woodpecker-ci/woodpecker/model"
|
||||||
)
|
)
|
||||||
@@ -52,17 +53,17 @@ func parseHook(r *http.Request) (*model.Repo, *model.Build, error) {
|
|||||||
|
|
||||||
// parsePushHook parses a push hook and returns the Repo and Build details.
|
// parsePushHook parses a push hook and returns the Repo and Build details.
|
||||||
// If the commit type is unsupported nil values are returned.
|
// If the commit type is unsupported nil values are returned.
|
||||||
func parsePushHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
func parsePushHook(payload io.Reader) (repo *model.Repo, build *model.Build, err error) {
|
||||||
var (
|
|
||||||
repo *model.Repo
|
|
||||||
build *model.Build
|
|
||||||
)
|
|
||||||
|
|
||||||
push, err := parsePush(payload)
|
push, err := parsePush(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore push events for tags
|
||||||
|
if strings.HasPrefix(push.Ref, "refs/tags/") {
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
// is this even needed?
|
// is this even needed?
|
||||||
if push.RefType == refBranch {
|
if push.RefType == refBranch {
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
@@ -75,12 +76,7 @@ func parsePushHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
|||||||
|
|
||||||
// parseCreatedHook parses a push hook and returns the Repo and Build details.
|
// parseCreatedHook parses a push hook and returns the Repo and Build details.
|
||||||
// If the commit type is unsupported nil values are returned.
|
// If the commit type is unsupported nil values are returned.
|
||||||
func parseCreatedHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
func parseCreatedHook(payload io.Reader) (repo *model.Repo, build *model.Build, err error) {
|
||||||
var (
|
|
||||||
repo *model.Repo
|
|
||||||
build *model.Build
|
|
||||||
)
|
|
||||||
|
|
||||||
push, err := parsePush(payload)
|
push, err := parsePush(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -92,7 +88,7 @@ func parseCreatedHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
|||||||
|
|
||||||
repo = repoFromPush(push)
|
repo = repoFromPush(push)
|
||||||
build = buildFromTag(push)
|
build = buildFromTag(push)
|
||||||
return repo, build, err
|
return repo, build, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsePullRequestHook parses a pull_request hook and returns the Repo and Build details.
|
// parsePullRequestHook parses a pull_request hook and returns the Repo and Build details.
|
||||||
|
Reference in New Issue
Block a user