Skip to content

Commit 2117e29

Browse files
committed
Merge pull request #3 from vbatts/add_travis
Add Travis
2 parents 9460d08 + fb62c6d commit 2117e29

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: go
2+
go:
3+
- 1.6
4+
- 1.5.3
5+
6+
sudo: false
7+
8+
before_install:
9+
- go get golang.org/x/tools/cmd/vet
10+
- go get -u github.com/golang/lint/golint
11+
- mkdir -p $GOPATH/src/github.com/vbatts && ln -sf $(pwd) $GOPATH/src/github.com/vbatts/git-validation && go get ./...
12+
13+
install: true
14+
15+
script:
16+
- go vet -x ./...
17+
- golint ./...
18+
- go build .
19+
- go test -v ./...
20+

main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log"
77
"os"
8+
"strings"
89

910
_ "github.com/vbatts/git-validation/rules/dco"
1011
_ "github.com/vbatts/git-validation/rules/shortsubject"
@@ -19,6 +20,7 @@ var (
1920
flDebug = flag.Bool("D", false, "debug output")
2021
flQuiet = flag.Bool("q", false, "less output")
2122
flDir = flag.String("d", ".", "git directory to validate from")
23+
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
2224
)
2325

2426
func main() {
@@ -44,7 +46,16 @@ func main() {
4446
rules = validate.FilterRules(rules, validate.SanitizeFilters(*flRun))
4547
}
4648

47-
runner, err := validate.NewRunner(*flDir, rules, *flCommitRange, *flVerbose)
49+
var commitRange = *flCommitRange
50+
if strings.ToLower(os.Getenv("TRAVIS")) == "true" && !*flNoTravis {
51+
if os.Getenv("TRAVIS_COMMIT_RANGE") != "" {
52+
commitRange = os.Getenv("TRAVIS_COMMIT_RANGE")
53+
} else if os.Getenv("TRAVIS_COMMIT") != "" {
54+
commitRange = os.Getenv("TRAVIS_COMMIT")
55+
}
56+
}
57+
58+
runner, err := validate.NewRunner(*flDir, rules, commitRange, *flVerbose)
4859
if err != nil {
4960
log.Fatal(err)
5061
}

0 commit comments

Comments
 (0)