From d54cfed1ad069d4e063a4c0463f96ba04060a36c Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 10 Aug 2020 10:00:46 -0300 Subject: assert-content.sh: Look at post refs too, not only pages --- scripts/assert-content.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'scripts') 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 -- cgit v1.2.3