diff options
Diffstat (limited to 'scripts/assert-content.sh')
-rwxr-xr-x | scripts/assert-content.sh | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh index 470fcb7..7448c61 100755 --- a/scripts/assert-content.sh +++ b/scripts/assert-content.sh @@ -84,20 +84,27 @@ done echo Asserting unique refs... >&2 KNOWN_IDS=() -for page in $(jq -r '.pages[] | @base64' "${JSON}"); do - URL="$(get-url "$page")" - if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then - LANG="$(get-lang "$page")" - REF="$(get-ref "$page")" - ID="${LANG}:${REF}" - - if contains-element "${ID}" "${KNOWN_IDS[@]}"; then - red "Duplicated lang:ref match: '${ID}'." >&2 - exit 1 +assert-unique-ref() { + for page in $1; do + URL="$(get-url "$page")" + if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then + LANG="$(get-lang "$page")" + REF="$(get-ref "$page")" + ID="${LANG}:${REF}" + + if contains-element "${ID}" "${KNOWN_IDS[@]}"; then + printf '%s\n' "${KNOWN_IDS[@]}" + red "Duplicated lang:ref match: '${ID}'." >&2 + red "Page: ${URL}." >&2 + exit 1 + fi + + KNOWN_IDS+=("${ID}") # printf '%s\n' "${KNOWN_IDS[@]}" fi + done +} - KNOWN_IDS+=("${ID}") # printf '%s\n' "${KNOWN_IDS[@]}" - fi -done +assert-unique-ref "$(jq -r '.pages[] | @base64' "${JSON}")" +assert-unique-ref "$(jq -r '.posts[] | @base64' "${JSON}")" echo Done. >&2 |