mirror of
https://github.com/vbatts/git-validation.git
synced 2024-12-28 08:16:31 +00:00
travis: only run the git-validation on pull-requests
Fixes #24 https://docs.travis-ci.com/user/pull-requests/ Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
e6a550d472
commit
56ef622e37
2 changed files with 15 additions and 8 deletions
|
@ -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
22
main.go
|
@ -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 != "" {
|
||||
|
|
Loading…
Reference in a new issue