aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-08-10 10:00:46 -0300
committerEuAndreh <eu@euandre.org>2020-08-10 10:00:46 -0300
commitd54cfed1ad069d4e063a4c0463f96ba04060a36c (patch)
treeb2000cbafadc30948b81eb0445f8de63352811f6 /scripts
parentFinish migrating til.md (diff)
downloadeuandre.org-d54cfed1ad069d4e063a4c0463f96ba04060a36c.tar.gz
euandre.org-d54cfed1ad069d4e063a4c0463f96ba04060a36c.tar.xz
assert-content.sh: Look at post refs too, not only pages
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/assert-content.sh33
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