github.com/pvitto98/fabric@v2.1.1+incompatible/scripts/check_trailingspaces.sh (about)

     1  #!/bin/bash
     2  # Copyright Hitachi, Ltd. All Rights Reserved.
     3  # SPDX-License-Identifier: Apache-2.0
     4  
     5  COMMIT_FILES=$(git diff --name-only --diff-filter=ACMRTUXB HEAD | grep -Ev '(^|/)vendor/')
     6  
     7  echo "Checking trailing spaces ..."
     8  for filename in $COMMIT_FILES; do
     9      if [[ $(file "$filename") == *"ASCII text"* ]]; then
    10          if grep -El " +$" "$filename"; then
    11              FOUND_TRAILING='yes'
    12              echo "Error: Trailing spaces found in file:$filename, lines:"
    13              grep -En " +$" "$filename"
    14          fi
    15      fi
    16  done
    17  
    18  if [[ -n ${FOUND_TRAILING+x} ]]; then
    19      echo "Please omit trailing spaces and make again."
    20      exit 1
    21  fi