github.com/dim4egster/coreth@v0.10.2/scripts/lint_allowed_geth_imports.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -o errexit
     4  set -o nounset
     5  set -o pipefail
     6  
     7  # Ensure that there are no geth imports that are not marked as explicitly allowed via ./scripts/geth-allowed-packages.txt
     8  # 1. Recursively search through all go files for any lines that include a direct import from go-ethereum
     9  # 2. Sort the unique results
    10  # #. Print out the difference between the search results and the list of specified allowed package imports from geth.
    11  extra_imports=$(grep -r --include='*.go' '"github.com/ethereum/go-ethereum/.*"' -o -h | sort -u | comm -23 - ./scripts/geth-allowed-packages.txt)
    12  if [ ! -z "${extra_imports}" ]; then
    13      echo "new go-ethereum imports should be added to ./scripts/geth-allowed-packages.txt to prevent accidental imports:"
    14      echo "${extra_imports}"
    15      exit 1
    16  fi