mirror of
https://github.com/vbatts/git-validation.git
synced 2024-11-29 19:45:39 +00:00
main: Return to using TRAVIS_COMMIT_RANGE (with ... -> .. fix)
Master builds only have a 'git clone ...' [1] so FETCH_HEAD isn't
defined and git-validation crashes [2]. This commit partially reverts
8a12a8fc
(main: default travis commit range is unreliable, 2017-03-21,
#13) to avoid that crash. If TRAVIS_COMMIT_RANGE is unset [3],
falling back to TRAVIS_COMMIT may be fine.
The ... -> .. replacement works around travis-ci/travis-ci#4596 until
that is fixed upstream [4]. This avoids pulling in commits from the
base tip that aren't reachable from the head tip (e.g. if master has
advanced since the PR branched off, and the PR is against master). We
only want to check commits that are in the head branch but not in the
base branch (more details on the range syntax in [5]).
Once the Travis bug does get fixed, the shell replacement will be a
no-op. So we don't have to worry about checks breaking once the bug
gets fixed, and can periodically poll the bug and remove the
workaround at out leisure after the fix.
[1]: https://travis-ci.org/opencontainers/runc/jobs/213508696#L243
[2]: https://travis-ci.org/opencontainers/runc/jobs/213508696#L347
[3]: https://github.com/opencontainers/runc/pull/1378#issuecomment-287903471
[4]: https://github.com/travis-ci/travis-ci/issues/4596
[5]: http://git-scm.com/docs/gitrevisions#_specifying_ranges
Signed-off-by: W. Trevor King <wking@tremily.us>
This commit is contained in:
parent
a5aad5a99b
commit
cdd7165f80
2 changed files with 3 additions and 2 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 ./...
|
- mkdir -p $GOPATH/src/github.com/vbatts && ln -sf $(pwd) $GOPATH/src/github.com/vbatts/git-validation && go get ./...
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- echo $TRAVIS_COMMIT_RANGE
|
||||||
- echo $TRAVIS_COMMIT
|
- echo $TRAVIS_COMMIT
|
||||||
- echo $TRAVIS_BRANCH
|
- echo $TRAVIS_BRANCH
|
||||||
- echo $TRAVIS_TAG
|
- echo $TRAVIS_TAG
|
||||||
|
|
4
main.go
4
main.go
|
@ -50,8 +50,8 @@ func main() {
|
||||||
var commitRange = *flCommitRange
|
var commitRange = *flCommitRange
|
||||||
if commitRange == "" {
|
if commitRange == "" {
|
||||||
if strings.ToLower(os.Getenv("TRAVIS")) == "true" && !*flNoTravis {
|
if strings.ToLower(os.Getenv("TRAVIS")) == "true" && !*flNoTravis {
|
||||||
if os.Getenv("TRAVIS_BRANCH") != "" {
|
if os.Getenv("TRAVIS_COMMIT_RANGE") != "" {
|
||||||
commitRange = fmt.Sprintf("%s..FETCH_HEAD", os.Getenv("TRAVIS_BRANCH"))
|
commitRange = strings.Replace("...", "..", os.Getenv("TRAVIS_COMMIT_RANGE"), 1)
|
||||||
} else if os.Getenv("TRAVIS_COMMIT") != "" {
|
} else if os.Getenv("TRAVIS_COMMIT") != "" {
|
||||||
commitRange = os.Getenv("TRAVIS_COMMIT")
|
commitRange = os.Getenv("TRAVIS_COMMIT")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue