aboutsummaryrefslogtreecommitdiffstats
path: root/tests/data/fetch.sh
blob: bf6832cde7e0e4e4b370f982e304fe2bdef25a48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
#
# Fetches release entity mentioned in verify.csv and cache them locally.

set -e -u
set -o pipefail

API="https://api.fatcat.wiki/v0"
CSV="verify.csv"

# Just release ATM, but could extend to other types.
mkdir -p release

for ident in $(awk -F, '{print $1"\n"$2}' "$CSV"); do
	dst="release/$ident"
	if [ -f "$dst" ]; then
		echo >&2 "[cached] $dst"
		continue
	fi
	tempfile=$(mktemp)
	curl -sL --fail "$API/release/$ident" | jq --sort-keys . >"$tempfile" && mv "$tempfile" "$dst"
	echo >&2 "[fetched] $dst"
done