github.com/MetalBlockchain/subnet-evm@v0.4.9/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' --exclude-dir='simulator' '"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
    17  
    18  extra_imports=$(grep -r --include='*.go' '"github.com/ava-labs/coreth/.*"' -o -h || true | sort -u)
    19  if [ ! -z "${extra_imports}" ]; then
    20      echo "subnet-evm should not import packages from coreth:"
    21      echo "${extra_imports}"
    22      exit 1
    23  fi