@@ -125,8 +125,12 @@ def get_files_for_linting():
125125 a remote branch to diff against.
126126 """
127127 diff_base = None
128- # Temporarily turning off origin/master check since file removed.
129- if os .getenv ('TRAVIS' ) is None :
128+ if (os .getenv ('TRAVIS_BRANCH' ) == 'master' and
129+ os .getenv ('TRAVIS_PULL_REQUEST' ) != 'false' ):
130+ # In the case of a pull request into master, we want to
131+ # diff against HEAD in master.
132+ diff_base = 'origin/master'
133+ elif os .getenv ('TRAVIS' ) is None :
130134 # Only allow specified remote and branch in local dev.
131135 remote = os .getenv ('GCLOUD_REMOTE_FOR_LINT' )
132136 branch = os .getenv ('GCLOUD_BRANCH_FOR_LINT' )
@@ -176,6 +180,12 @@ def get_python_files():
176180
177181def lint_fileset (filenames , rcfile , description ):
178182 """Lints a group of files using a given rcfile."""
183+ # Only lint filenames that exist. For example, 'git diff --name-only'
184+ # could spit out deleted / renamed files. Another alternative could
185+ # be to use 'git diff --name-status' and filter out files with a
186+ # status of 'D'.
187+ filenames = [filename for filename in filenames
188+ if os .path .exists (filename )]
179189 if filenames :
180190 rc_flag = '--rcfile=%s' % (rcfile ,)
181191 pylint_shell_command = ['pylint' , rc_flag ] + filenames
0 commit comments