lint_pull_request.sh 656 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. #
  3. # Script to run the Compiler's Linter on only the modified or added files in the
  4. # current branch. Should be run from the base git directory with the PR branch
  5. # checked out.
  6. CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
  7. CHANGED_FILES=$(git diff --name-only --diff-filter=AM master..$CURRENT_BRANCH |
  8. grep -E "\.js$" |
  9. grep -v -E "test\.js$" |
  10. grep -v -f scripts/ci/lint_ignore.txt)
  11. if [[ -n "$CHANGED_FILES" ]]; then
  12. set -x
  13. java -jar \
  14. ../closure-compiler/target/closure-compiler-linter-1.0-SNAPSHOT.jar \
  15. $CHANGED_FILES
  16. else
  17. echo "No .js files found to lint in this Pull Request."
  18. fi