Merge pull request #29 from vbatts/fix_push_ci

travis: only run the git-validation on pull-requests
This commit is contained in:
Vincent Batts 2017-04-27 14:04:18 -04:00 committed by GitHub
commit ac0930a271
2 changed files with 15 additions and 8 deletions

View File

@ -11,6 +11,7 @@ before_install:
- mkdir -p $GOPATH/src/github.com/vbatts && ln -sf $(pwd) $GOPATH/src/github.com/vbatts/git-validation && go get ./...
before_script:
- env
- echo $TRAVIS_COMMIT_RANGE
- echo $TRAVIS_COMMIT
- echo $TRAVIS_BRANCH

22
main.go
View File

@ -14,14 +14,15 @@ import (
)
var (
flCommitRange = flag.String("range", "", "use this commit range instead (implies -no-travis)")
flListRules = flag.Bool("list-rules", false, "list the rules registered")
flRun = flag.String("run", "", "comma delimited list of rules to run. Defaults to all.")
flVerbose = flag.Bool("v", false, "verbose")
flDebug = flag.Bool("D", false, "debug output")
flQuiet = flag.Bool("q", false, "less output")
flDir = flag.String("d", ".", "git directory to validate from")
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
flCommitRange = flag.String("range", "", "use this commit range instead (implies -no-travis)")
flListRules = flag.Bool("list-rules", false, "list the rules registered")
flRun = flag.String("run", "", "comma delimited list of rules to run. Defaults to all.")
flVerbose = flag.Bool("v", false, "verbose")
flDebug = flag.Bool("D", false, "debug output")
flQuiet = flag.Bool("q", false, "less output")
flDir = flag.String("d", ".", "git directory to validate from")
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
flTravisPROnly = flag.Bool("travis-pr-only", true, "when on travis, only run validations if the CI-Build is checking pull-request build")
)
func main() {
@ -41,6 +42,11 @@ func main() {
return
}
if *flTravisPROnly && strings.ToLower(os.Getenv("TRAVIS_PULL_REQUEST")) == "false" {
fmt.Printf("only to check travis PR builds and this not a PR build. yielding.\n")
return
}
// reduce the set being run
rules := validate.RegisteredRules
if *flRun != "" {