Skip to content

Commit 1d0289a

Browse files
author
Dean Karn
committed
temp checkin
1 parent e452811 commit 1d0289a

File tree

13 files changed

+2798
-2826
lines changed

13 files changed

+2798
-2826
lines changed

.travis.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,20 @@ before_install:
1616
- go get -u github.com/go-playground/overalls
1717
- go get -u github.com/mattn/goveralls
1818
- go get -u golang.org/x/tools/cmd/cover
19-
- go get -u github.com/golang/lint/golint
20-
- go get -u github.com/gordonklaus/ineffassign
2119
- mkdir -p $GOPATH/src/gopkg.in
2220
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v2
2321
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v3
2422
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v4
2523
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v5
2624

2725
before_script:
28-
- go vet ./...
26+
- go get -t ./...
2927

3028
script:
31-
- gofmt -d -s .
32-
- golint ./...
33-
- ineffassign ./
34-
- go test -v ./...
35-
- go test -race
29+
- make lint
30+
- make test
3631

3732
after_success: |
3833
[ $TRAVIS_GO_VERSION = 1.10.3 ] &&
39-
overalls -project="github.com/go-playground/webhooks" -covermode=count -ignore=.git,examples -debug &&
34+
overalls -project="github.com/go-playground/webhooks" -covermode=count -ignore=.git,_examples,testdata -debug &&
4035
goveralls -coverprofile=overalls.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
GOCMD=go
2+
3+
linters-install:
4+
@gometalinter --version >/dev/null 2>&1 || { \
5+
echo "installing linting tools..."; \
6+
$(GOCMD) get github.com/alecthomas/gometalinter; \
7+
gometalinter --install; \
8+
}
9+
10+
lint: linters-install
11+
@gofmt -l . >gofmt.test 2>&1 && if [ -s gofmt.test ]; then echo "Fix formatting using 'gofmt -s -w .' for:"; cat gofmt.test; exit 1; fi && rm gofmt.test
12+
gometalinter --vendor --disable-all --enable=vet --enable=vetshadow --enable=golint --enable=maligned --enable=megacheck --enable=ineffassign --enable=misspell --enable=errcheck --enable=goconst ./...
13+
14+
test:
15+
$(GOCMD) test -cover -race ./...
16+
17+
.PHONY: test lint linters-install
File renamed without changes.
File renamed without changes.
File renamed without changes.

bitbucket/bitbucket.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
"net/http"
1010
)
1111

12-
// parse errros
12+
// parse errors
1313
var (
14-
ErrEventNotSpecifiedToParse = errors.New("No Event specified to parse")
15-
ErrInvalidHTTPMethod = errors.New("Invalid HTTP Method")
16-
ErrMissingHookUUIDHeader = errors.New("Missing X-Hook-UUID Header")
17-
ErrMissingEventKeyHeader = errors.New("Missing X-Event-Key Header")
18-
ErrEventNotFound = errors.New("Event not defined to be parsed")
19-
ErrParsingPayload = errors.New("Error parsing payload")
14+
ErrEventNotSpecifiedToParse = errors.New("no Event specified to parse")
15+
ErrInvalidHTTPMethod = errors.New("invalid HTTP Method")
16+
ErrMissingHookUUIDHeader = errors.New("missing X-Hook-UUID Header")
17+
ErrMissingEventKeyHeader = errors.New("missing X-Event-Key Header")
18+
ErrEventNotFound = errors.New("event not defined to be parsed")
19+
ErrParsingPayload = errors.New("error parsing payload")
2020
ErrUUIDVerificationFailed = errors.New("UUID verification failed")
2121
)
2222

@@ -96,15 +96,16 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
9696
if uuid == "" {
9797
return nil, ErrMissingHookUUIDHeader
9898
}
99-
if len(hook.uuid) > 0 && uuid != hook.uuid {
100-
return nil, ErrUUIDVerificationFailed
101-
}
10299

103100
event := r.Header.Get("X-Event-Key")
104101
if event == "" {
105102
return nil, ErrMissingEventKeyHeader
106103
}
107104

105+
if len(hook.uuid) > 0 && uuid != hook.uuid {
106+
return nil, ErrUUIDVerificationFailed
107+
}
108+
108109
bitbucketEvent := Event(event)
109110

110111
var found bool

0 commit comments

Comments
 (0)