debug git more
This commit is contained in:
parent
35aa99149a
commit
e8d14cd081
1 changed files with 6 additions and 8 deletions
|
|
@ -39,16 +39,14 @@ install_lightning_pub() {
|
|||
# Get latest commit hash from GitHub API, logging the response for debugging.
|
||||
API_RESPONSE=$(wget -qO- "https://api.github.com/repos/${REPO}/commits/${BRANCH}" 2>&1 | tee /tmp/api_response.log)
|
||||
|
||||
# Check for a rate limit error first.
|
||||
if echo "$API_RESPONSE" | grep -q "API rate limit exceeded"; then
|
||||
# Parse commit hash from the commit html_url first (most robust, dependency-free)
|
||||
LATEST_COMMIT=$(echo "$API_RESPONSE" | awk -F'[/"]' '/"html_url": ".*\/commit\// {print $(NF-1); exit}')
|
||||
|
||||
# If parsing failed, check explicitly for a rate-limit message; otherwise abort with full response
|
||||
if [ -z "$LATEST_COMMIT" ]; then
|
||||
if grep -q '"message"[[:space:]]*:[[:space:]]*"API rate limit exceeded"' <<< "$API_RESPONSE"; then
|
||||
log_error "GitHub API rate limit exceeded. Please wait a while before trying again." 1
|
||||
fi
|
||||
|
||||
# Safely parse the JSON using awk to extract the commit hash from the stable "html_url" field.
|
||||
LATEST_COMMIT=$(echo "$API_RESPONSE" | awk -F'[/"]' '/"html_url": ".*\/commit\// {print $(NF-1)}')
|
||||
|
||||
# If we still couldn't get the commit, it's a different network or API error.
|
||||
if [ -z "$LATEST_COMMIT" ]; then
|
||||
log "GitHub API response was not as expected. Full response for debugging:"
|
||||
log "$API_RESPONSE"
|
||||
log_error "Could not retrieve latest version from GitHub. Upgrade check failed. Aborting." 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue