Skip to content

Commit

Permalink
Merge pull request #112 from euank/gimme-pagination
Browse files Browse the repository at this point in the history
Paginate bucket in 'gimme stable'
  • Loading branch information
philpennock authored Jan 15, 2018
2 parents 78bb4bc + c6928a4 commit 711dc29
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gimme
Original file line number Diff line number Diff line change
Expand Up @@ -439,20 +439,20 @@ _get_curr_stable() {

_update_stable() {
local stable="${1}"
local exp="go([[:digit:]\.]*)\.src.*"
local tmp_versions="${GIMME_TMP}/versions"
local url="https://www.googleapis.com/storage/v1/b/golang/o?fields=items%2Fname&maxResults=999999"
local url="https://www.googleapis.com/storage/v1/b/golang/o?fields=items%2Fname,nextPageToken"
local vers=""
local nextPageToken

mkdir -p "$(dirname "${stable}")"

_do_curl "${url}" "${tmp_versions}"
vers="$(jq -r '.items[].name | capture("go(?<ver>[[:digit:]\\.]*)\\.src.*").ver' <"$tmp_versions")"

while read -r line; do
if [[ "${line}" =~ ${exp} ]]; then
vers="$vers\n${BASH_REMATCH[1]}"
fi
done <"${tmp_versions}"
while nextPageToken=$(jq --exit-status --raw-output '.nextPageToken' <"$tmp_versions"); do
_do_curl "${url}&pageToken=${nextPageToken}" "${tmp_versions}"
vers="${vers}\n$(jq -r '.items[].name | capture("go(?<ver>[[:digit:]\\.]*)\\.src.*").ver' <"$tmp_versions")"
done

rm -f "${tmp_versions}" &>/dev/null
echo -e "${vers}" | sort -n -r | head -n1 >"${stable}"
Expand Down

0 comments on commit 711dc29

Please sign in to comment.