Apply linter pre-commit hook only to Added/Copied/Modified

it will fail on deleted/renamed files.

Change-Id: I4285f0f9ccc4f2b6c875816c4df25a15fd20222b
This commit is contained in:
Tao Zhou 2020-02-03 14:34:58 +01:00
parent 79070a7adb
commit abf0489e74

View File

@ -31,7 +31,7 @@ gitroot=${gitroot:-.};
eslint=${gitroot}/node_modules/eslint/bin/eslint.js
# Run eslint over changed frontend code
CHANGED_UI_FILES=$(git diff --cached --name-only -- '*.js' '*.html' | grep 'polygerrit-ui') && true
CHANGED_UI_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.js' '*.html' | grep 'polygerrit-ui') && true
if [ "${CHANGED_UI_FILES}" ]; then
if $eslint --fix ${CHANGED_UI_FILES}; then
# Add again in case lint fix modified some files