github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/scripts/functions.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright hechain. All Rights Reserved.
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  
     7  function filterExcludedAndGeneratedFiles {
     8      local excluded_files
     9      excluded_files=(
    10          '\.block$'
    11          '^\.build/'
    12          '^build/'
    13          '(^|/)ci\.properties$'
    14          '(^|/)\.git/'
    15          '\.gen\.go$'
    16          '(^|/)go.mod$'
    17          '(^|/)go.sum$'
    18          '(^|/)Gopkg\.lock$'
    19          '\.html$'
    20          '\.json$'
    21          '\.key$'
    22          '(^|/)LICENSE$'
    23          '\.md$'
    24          '\.pb\.go$'
    25          '\.pem$'
    26          '\.png$'
    27          '\.pptx$'
    28          '\.rst$'
    29          '_sk$'
    30          '\.tx$'
    31          '\.txt$'
    32          '^NOTICE$'
    33          '(^|/)testdata\/'
    34          '(^|/)vendor\/'
    35          '(^|/)Pipfile$'
    36          '(^|/)Pipfile\.lock$'
    37          '(^|/)tox\.ini$'
    38      )
    39  
    40      local filter
    41      filter=$(local IFS='|' ; echo "${excluded_files[*]}")
    42  
    43      read -rd '' -a files <<<"$@"
    44      for f in "${files[@]}"; do
    45          file=$(echo "$f" | grep -Ev "$filter" | sort -u)
    46          if [ -n "$file" ]; then
    47              head -n8 "$file" | grep -qE '// Code generated by' || echo "$file"
    48          fi
    49      done
    50  }