Skip to content

Commit ac0930a

Browse files
authored
Merge pull request #29 from vbatts/fix_push_ci
travis: only run the git-validation on pull-requests
2 parents e6a550d + 56ef622 commit ac0930a

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ before_install:
1111
- mkdir -p $GOPATH/src/github.com/vbatts && ln -sf $(pwd) $GOPATH/src/github.com/vbatts/git-validation && go get ./...
1212

1313
before_script:
14+
- env
1415
- echo $TRAVIS_COMMIT_RANGE
1516
- echo $TRAVIS_COMMIT
1617
- echo $TRAVIS_BRANCH

main.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import (
1414
)
1515

1616
var (
17-
flCommitRange = flag.String("range", "", "use this commit range instead (implies -no-travis)")
18-
flListRules = flag.Bool("list-rules", false, "list the rules registered")
19-
flRun = flag.String("run", "", "comma delimited list of rules to run. Defaults to all.")
20-
flVerbose = flag.Bool("v", false, "verbose")
21-
flDebug = flag.Bool("D", false, "debug output")
22-
flQuiet = flag.Bool("q", false, "less output")
23-
flDir = flag.String("d", ".", "git directory to validate from")
24-
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
17+
flCommitRange = flag.String("range", "", "use this commit range instead (implies -no-travis)")
18+
flListRules = flag.Bool("list-rules", false, "list the rules registered")
19+
flRun = flag.String("run", "", "comma delimited list of rules to run. Defaults to all.")
20+
flVerbose = flag.Bool("v", false, "verbose")
21+
flDebug = flag.Bool("D", false, "debug output")
22+
flQuiet = flag.Bool("q", false, "less output")
23+
flDir = flag.String("d", ".", "git directory to validate from")
24+
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
25+
flTravisPROnly = flag.Bool("travis-pr-only", true, "when on travis, only run validations if the CI-Build is checking pull-request build")
2526
)
2627

2728
func main() {
@@ -41,6 +42,11 @@ func main() {
4142
return
4243
}
4344

45+
if *flTravisPROnly && strings.ToLower(os.Getenv("TRAVIS_PULL_REQUEST")) == "false" {
46+
fmt.Printf("only to check travis PR builds and this not a PR build. yielding.\n")
47+
return
48+
}
49+
4450
// reduce the set being run
4551
rules := validate.RegisteredRules
4652
if *flRun != "" {

0 commit comments

Comments
 (0)