Skip to content

Commit 3f4278c

Browse files
committed
review feedback + enhancements from PR 343
1 parent 97a4fb8 commit 3f4278c

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

bin/install-latest-linux.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
set -eo pipefail
33

44
# Fetch release metadata from GitHub API
5-
API_RESPONSE="$(curl -sf https://api.github.com/repos/brevdev/brev-cli/releases/latest 2>&1)" || {
5+
API_RESPONSE="$(curl -sf ${GITHUB_TOKEN:+-H "Authorization: token ${GITHUB_TOKEN}"} https://api.github.com/repos/brevdev/brev-cli/releases/latest)" || {
66
echo "Error: Failed to fetch release info from GitHub API." >&2
7-
echo "This may be caused by rate limiting. Try again later or set a GITHUB_TOKEN." >&2
7+
echo "This is often caused by rate limiting when many requests come from the same IP." >&2
8+
echo "If you are using a VPN, try turning it off and running this script again." >&2
9+
echo "You can also set GITHUB_TOKEN to avoid rate limits." >&2
10+
echo "For more details, see: https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting" >&2
811
exit 1
912
}
1013

1114
# Extract the download URL for linux/amd64
1215
DOWNLOAD_URL="$(echo "${API_RESPONSE}" | grep "browser_download_url.*linux.*amd64" | cut -d '"' -f 4)"
1316
if [ -z "${DOWNLOAD_URL}" ]; then
1417
echo "Error: Could not find release for linux amd64" >&2
18+
echo "GitHub API response (truncated): ${API_RESPONSE:0:200}" >&2
1519
exit 1
1620
fi
1721

bin/install-latest.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ case "${ARCH}" in
1010
esac
1111

1212
# Fetch release metadata from GitHub API
13-
API_RESPONSE="$(curl -sf https://api.github.com/repos/brevdev/brev-cli/releases/latest 2>&1)" || {
13+
API_RESPONSE="$(curl -sf ${GITHUB_TOKEN:+-H "Authorization: token ${GITHUB_TOKEN}"} https://api.github.com/repos/brevdev/brev-cli/releases/latest)" || {
1414
echo "Error: Failed to fetch release info from GitHub API." >&2
15-
echo "This may be caused by rate limiting. Try again later or set a GITHUB_TOKEN." >&2
15+
echo "This is often caused by rate limiting when many requests come from the same IP." >&2
16+
echo "If you are using a VPN, try turning it off and running this script again." >&2
17+
echo "You can also set GITHUB_TOKEN to avoid rate limits." >&2
18+
echo "For more details, see: https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting" >&2
1619
exit 1
1720
}
1821

1922
# Extract the download URL for this platform
2023
DOWNLOAD_URL="$(echo "${API_RESPONSE}" | grep "browser_download_url.*${OS}.*${ARCH}" | cut -d '"' -f 4)"
2124
if [ -z "${DOWNLOAD_URL}" ]; then
2225
echo "Error: Could not find release for ${OS} ${ARCH}" >&2
26+
echo "GitHub API response (truncated): ${API_RESPONSE:0:200}" >&2
2327
exit 1
2428
fi
2529

scripts/install-agent-skill.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,21 @@ done
116116
rm -rf "$TMPDIR"
117117

118118
# Resolve commit SHA and write .version file
119-
COMMIT_SHA=$(curl -fsSL "https://api.github.com/repos/$REPO/commits/$BRANCH" 2>/dev/null | grep '"sha"' | head -1 | sed 's/.*"sha": *"\([^"]*\)".*/\1/')
120-
if [[ -n "$COMMIT_SHA" ]]; then
121-
for dir in "${INSTALL_DIRS[@]}"; do
122-
printf 'branch=%s\ncommit=%s\n' "$BRANCH" "$COMMIT_SHA" > "$dir/.version"
123-
done
124-
echo -e " ${GREEN}${NC} .version (${COMMIT_SHA:0:12})"
119+
VERSION_RESPONSE=$(curl -fsSL "https://api.github.com/repos/$REPO/commits/$BRANCH" 2>&1) || true
120+
if echo "$VERSION_RESPONSE" | grep -q "API rate limit exceeded"; then
121+
echo -e " ${YELLOW}${NC} .version (skipped — GitHub API rate limit exceeded)"
122+
echo -e " ${YELLOW}If you are using a VPN, try turning it off and running this script again.${NC}"
123+
echo -e " ${YELLOW}See: https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting${NC}"
124+
else
125+
COMMIT_SHA=$(echo "$VERSION_RESPONSE" | grep '"sha"' | head -1 | sed 's/.*"sha": *"\([^"]*\)".*/\1/')
126+
if [[ -n "$COMMIT_SHA" ]]; then
127+
for dir in "${INSTALL_DIRS[@]}"; do
128+
printf 'branch=%s\ncommit=%s\n' "$BRANCH" "$COMMIT_SHA" > "$dir/.version"
129+
done
130+
echo -e " ${GREEN}${NC} .version (${COMMIT_SHA:0:12})"
131+
else
132+
echo -e " ${YELLOW}${NC} .version (could not resolve commit SHA)"
133+
fi
125134
fi
126135

127136
echo ""

0 commit comments

Comments
 (0)