From 2e242169b929153a4ed7640fc19a412d6c7be1e2 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Mon, 21 Aug 2023 16:49:53 -0700 Subject: [PATCH] fallback to querying each repo if querying all of them fails (due to SAML errors) --- features/src/utils/devcontainer-feature.json | 2 +- .../utils/opt/devcontainer/bin/github/repo/clone.sh | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/features/src/utils/devcontainer-feature.json b/features/src/utils/devcontainer-feature.json index 3512dc32..93b7fb4e 100644 --- a/features/src/utils/devcontainer-feature.json +++ b/features/src/utils/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "devcontainer-utils", "id": "utils", - "version": "23.10.4", + "version": "23.10.5", "description": "A feature to install RAPIDS devcontainer utility scripts", "containerEnv": { "BASH_ENV": "/etc/bash.bash_env" diff --git a/features/src/utils/opt/devcontainer/bin/github/repo/clone.sh b/features/src/utils/opt/devcontainer/bin/github/repo/clone.sh index bf2d974c..092f7249 100755 --- a/features/src/utils/opt/devcontainer/bin/github/repo/clone.sh +++ b/features/src/utils/opt/devcontainer/bin/github/repo/clone.sh @@ -32,8 +32,7 @@ get_user_fork_name() { if [ "${user}" = "${owner}" ]; then echo "${owner}/${name}"; else - gh repo list "${user}" --fork --json nameWithOwner --json parent --jq "$(cat <<________EOF | tr -s '[:space:]' - . + local query="$(cat <<________EOF | tr -s '[:space:]' | map(select( .parent.name == "${name}" and @@ -42,6 +41,16 @@ get_user_fork_name() { | map(.nameWithOwner)[] ________EOF )"; + local nameWithOwner="$(gh repo list "${user}" --fork --json nameWithOwner --json parent --jq ". ${query}" 2>/dev/null || echo "")"; + if test -z "${nameWithOwner}"; then + for repo in $(gh repo list "${user}" --fork --json name --jq 'map(.name)[]'); do + nameWithOwner="$(gh repo view "${repo}" --json nameWithOwner --json parent --jq "[.] ${query}" 2>/dev/null || echo "")"; + if test -n "${nameWithOwner}"; then + break; + fi + done + fi + echo -n "${nameWithOwner:-}"; fi }