Skip to content

Commit

Permalink
Ignore pushes to tags for gitea (#289)
Browse files Browse the repository at this point in the history
closes #274
  • Loading branch information
anbraten committed Aug 31, 2021
1 parent 34cfabb commit d15769b
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions remote/gitea/parse.go
Expand Up @@ -17,6 +17,7 @@ package gitea
import (
"io"
"net/http"
"strings"

"github.com/woodpecker-ci/woodpecker/model"
)
Expand Down Expand Up @@ -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.
// If the commit type is unsupported nil values are returned.
func parsePushHook(payload io.Reader) (*model.Repo, *model.Build, error) {
var (
repo *model.Repo
build *model.Build
)

func parsePushHook(payload io.Reader) (repo *model.Repo, build *model.Build, err error) {
push, err := parsePush(payload)
if err != nil {
return nil, nil, err
}

// ignore push events for tags
if strings.HasPrefix(push.Ref, "refs/tags/") {
return nil, nil, nil
}

// is this even needed?
if push.RefType == refBranch {
return nil, nil, nil
Expand All @@ -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.
// If the commit type is unsupported nil values are returned.
func parseCreatedHook(payload io.Reader) (*model.Repo, *model.Build, error) {
var (
repo *model.Repo
build *model.Build
)

func parseCreatedHook(payload io.Reader) (repo *model.Repo, build *model.Build, err error) {
push, err := parsePush(payload)
if err != nil {
return nil, nil, err
Expand All @@ -92,7 +88,7 @@ func parseCreatedHook(payload io.Reader) (*model.Repo, *model.Build, error) {

repo = repoFromPush(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.
Expand Down

0 comments on commit d15769b

Please sign in to comment.