Lint script tweaks (#13093)

* Also lint working tree files

When performing a git diff of upstream/dev..., git is diffing against
the current HEAD, but does not include working tree files. By manually
calculating a merge-base SHA to diff against, git will still diff those
files.

* Don't pylint tests files, since we don't in CI

* Use merge base for lazytox

* Simplify files changed header
pull/13100/merge
Adam Mills 2018-03-11 16:15:09 -04:00 committed by GitHub
parent 991c457430
commit 14aa4e7694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -94,7 +94,9 @@ async def git():
"""Exec git.""" """Exec git."""
if len(sys.argv) > 2 and sys.argv[1] == '--': if len(sys.argv) > 2 and sys.argv[1] == '--':
return sys.argv[2:] return sys.argv[2:]
_, log = await async_exec('git', 'diff', 'upstream/dev...', '--name-only') _, log = await async_exec('git', 'merge-base', 'upstream/dev', 'HEAD')
merge_base = log.splitlines()[0]
_, log = await async_exec('git', 'diff', merge_base, '--name-only')
return log.splitlines() return log.splitlines()

View File

@ -3,10 +3,10 @@
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
export files="`git diff upstream/dev... --diff-filter=d --name-only | grep -e '\.py$'`" export files="$(git diff $(git merge-base upstream/dev HEAD) --diff-filter=d --name-only | grep -e '\.py$')"
echo "=================================================" echo '================================================='
echo "FILES CHANGED (git diff upstream/dev... --diff-filter=d --name-only)" echo '= FILES CHANGED ='
echo "=================================================" echo '================================================='
if [ -z "$files" ] ; then if [ -z "$files" ] ; then
echo "No python file changed. Rather use: tox -e lint" echo "No python file changed. Rather use: tox -e lint"
exit exit
@ -19,5 +19,5 @@ flake8 --doctests $files
echo "================" echo "================"
echo "LINT with pylint" echo "LINT with pylint"
echo "================" echo "================"
pylint $files pylint $(echo "$files" | grep -v '^tests.*')
echo echo