diff --git a/bin/common.sh b/bin/common.sh index 32f0ee3..fb98a35 100644 --- a/bin/common.sh +++ b/bin/common.sh @@ -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" +} diff --git a/bin/in b/bin/in index b0d5e56..ae413f1 100755 --- a/bin/in +++ b/bin/in @@ -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" \ '{