github.com/kaituanwang/hyperledger@v2.0.1+incompatible/scripts/check_spelling.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright IBM Corp. All Rights Reserved.
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  filter() {
     9      while read -r data; do
    10          grep -Ev '^CHANGELOG|\.git|\.png$|^vendor/' <<< "$data"
    11      done
    12  }
    13  
    14  CHECK=$(git diff --name-only HEAD -- * | filter)
    15  
    16  if [[ -z "$CHECK" ]]; then
    17      CHECK=$(git diff-tree --no-commit-id --name-only -r HEAD^..HEAD | filter)
    18  fi
    19  
    20  echo "Checking changed go files for spelling errors ..."
    21  errs=$(echo "$CHECK" | xargs misspell -source=text)
    22  if [ -z "$errs" ]; then
    23      echo "spell checker passed"
    24      exit 0
    25  fi
    26  echo "The following files are have spelling errors:"
    27  echo "$errs"
    28  exit 0