3131
3232from script_utils import LOCAL_BRANCH_ENV
3333from script_utils import LOCAL_REMOTE_ENV
34+ from script_utils import in_travis
35+ from script_utils import in_travis_pr
36+ from script_utils import travis_branch
3437
3538
3639IGNORED_DIRECTORIES = [
@@ -146,10 +149,10 @@ def get_files_for_linting(allow_limited=True):
146149 against for changed files. (This requires ``allow_limited=True``.)
147150
148151 To speed up linting on Travis pull requests against master, we manually
149- set the diff base to origin/master . We don't do this on non-pull requests
150- since origin/ master will be equivalent to the currently checked out code.
151- One could potentially use ${TRAVIS_COMMIT_RANGE} to find a diff base but
152- this value is not dependable.
152+ set the diff base to the branch the pull request is against . We don't do
153+ this on "push" builds since " master" will be the currently checked out
154+ code. One could potentially use ${TRAVIS_COMMIT_RANGE} to find a diff base
155+ but this value is not dependable.
153156
154157 To allow faster local ``tox`` runs, the local remote and local branch
155158 environment variables can be set to specify a remote branch to diff
@@ -164,12 +167,12 @@ def get_files_for_linting(allow_limited=True):
164167 linted.
165168 """
166169 diff_base = None
167- if ( os . getenv ( 'TRAVIS_BRANCH' ) == 'master' and
168- os . getenv ( 'TRAVIS_PULL_REQUEST' ) != 'false' ):
169- # In the case of a pull request into master, we want to
170- # diff against HEAD in master.
171- diff_base = 'origin/master'
172- elif os . getenv ( 'TRAVIS' ) is None :
170+ if in_travis ():
171+ # In the case of a pull request into a branch, we want to
172+ # diff against HEAD in that branch.
173+ if in_travis_pr ():
174+ diff_base = travis_branch ()
175+ else :
173176 # Only allow specified remote and branch in local dev.
174177 remote = os .getenv (LOCAL_REMOTE_ENV )
175178 branch = os .getenv (LOCAL_BRANCH_ENV )
0 commit comments