Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,32 @@ curlgh () {
fi
curl $skip_verify_arg -s -H "Authorization: token $source_access_token" $@
}

curlgh_all_pages_status () {
results=''
page=0
present='true'
while [ "$present" = "true" ]; do
page=$(($page+1))
current_results=$(curlgh "$@?page=$page")

# Save the first query as the return value, in case the response
# body is not expected, the response body can still be returned
# and behave like curlgh would in the non-happy path.
if [ -z "$results" ]; then
results="$current_results"
continue
fi

# If key "statuses" is not present, stop iterating loop
statuses=$(echo $current_results | jq -c '.statuses // []')
if [ "$statuses" != "[]" ]; then
# Identify "statuses" array in `current_results` and append it to "statuses" array in `results`
results=$(echo "$results" | jq --argjson s "$statuses" '.statuses += $s')
else
present='false'
fi
done

echo "$results"
}
2 changes: 1 addition & 1 deletion bin/in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ eval $( jq -r '{
# lookup
#

curlgh "$source_endpoint/repos/$source_repository/commits/$version_commit/status?per_page=100" \
curlgh_all_pages_status "$source_endpoint/repos/$source_repository/commits/$version_commit/status" \
| jq -c \
--arg status "$version_status" \
'{
Expand Down