From 17d08f746b51fa70911754d36a799c247a2c4b79 Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Mon, 2 Dec 2024 13:03:58 -0800 Subject: [PATCH] scripts/gen-deps: filter out grpc modules (#7890) --- scripts/common.sh | 7 +++++++ scripts/gen-deps.sh | 4 +++- scripts/vet.sh | 7 ------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/common.sh b/scripts/common.sh index dede0789840f..3e641bae4c6c 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -11,6 +11,13 @@ not() { ! "$@" } +# noret_grep will return 0 if zero or more lines were selected, and >1 if an +# error occurred. Suppresses grep's return code of 1 when there are no matches +# (for eg, empty file). +noret_grep() { + grep "$@" || [[ $? == 1 ]] +} + die() { echo "$@" >&2 exit 1 diff --git a/scripts/gen-deps.sh b/scripts/gen-deps.sh index bc647c4d8cba..f4d5ec63e9c6 100755 --- a/scripts/gen-deps.sh +++ b/scripts/gen-deps.sh @@ -3,6 +3,8 @@ set -e # Exit on error set -o pipefail # Fail a pipe if any sub-command fails. +source "$(dirname $0)/common.sh" + if [[ "$#" -ne 1 || ! -d "$1" ]]; then echo "Specify a valid output directory as the first parameter." exit 1 @@ -16,6 +18,6 @@ cd "${SCRIPTS_DIR}/.." git ls-files -- '*.go' | grep -v '\(^\|/\)\(internal\|examples\|benchmark\|interop\|test\|testdata\)\(/\|$\)' | xargs dirname | sort -u | while read d; do pushd "$d" > /dev/null pkg="$(echo "$d" | sed 's;\.;grpc;' | sed 's;/;_;g')" - go list -deps . | sort >| "${OUTPUT_DIR}/$pkg" + go list -deps . | sort | noret_grep -v 'google.golang.org/grpc' >| "${OUTPUT_DIR}/$pkg" popd > /dev/null done diff --git a/scripts/vet.sh b/scripts/vet.sh index 8db7e19c5364..8c63af4cf008 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -8,13 +8,6 @@ source "$(dirname $0)/common.sh" # Check to make sure it's safe to modify the user's git repo. git status --porcelain | fail_on_output -# noret_grep will return 0 if zero or more lines were selected, and >1 if an -# error occurred. Suppresses grep's return code of 1 when there are no matches -# (for eg, empty file). -noret_grep() { - grep "$@" || [[ $? == 1 ]] -} - # Undo any edits made by this script. cleanup() { git reset --hard HEAD