aboutsummaryrefslogtreecommitdiff
path: root/scripts/assert-todos.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-01-12 17:42:27 -0300
committerEuAndreh <eu@euandre.org>2021-01-12 17:42:27 -0300
commit713c1b61c629f0f1a3aba7a03d29c58d173b5891 (patch)
tree2c70e33f06689c939f33967fbb20bdb0819ff02c /scripts/assert-todos.sh
parentAwk TIL: tweak introdction (diff)
downloadeuandre.org-713c1b61c629f0f1a3aba7a03d29c58d173b5891.tar.gz
euandre.org-713c1b61c629f0f1a3aba7a03d29c58d173b5891.tar.xz
Use longer version of assert-todos.sh
Diffstat (limited to '')
-rwxr-xr-xscripts/assert-todos.sh33
1 files changed, 32 insertions, 1 deletions
diff --git a/scripts/assert-todos.sh b/scripts/assert-todos.sh
index be3974a..dabe680 100755
--- a/scripts/assert-todos.sh
+++ b/scripts/assert-todos.sh
@@ -1,7 +1,38 @@
-#!/bin/sh -eux
+#!/bin/sh -eu
if git grep FIXME | grep -Ev '^(vendor/|scripts/assert-todos.sh|locale/)'; then
echo "Found dangling FIXME markers on the project."
echo "You should write them down properly on TODOs.org."
exit 1
fi
+
+KNOWN_IDS=''
+has_error=0
+# shellcheck disable=2013
+for todo in $(sed -e '/^\* Tasks$/,/^\* Improvements$/!d' TODOs.org | grep -nE '^\*\* .*$' | cut -d: -f1); do
+ if sed "${todo}q;d" TODOs.org | grep -qE '^\*\* (CANCELLED|DONE)'; then
+ ID_OFFSET=3
+ else
+ ID_OFFSET=2
+ fi
+ line_n="$((todo+ID_OFFSET))"
+ ID_LINE="$(sed "${line_n}q;d" TODOs.org)"
+ if echo "$ID_LINE" | grep -q '^:CUSTOM_ID: .*$'; then
+ ID="$(echo "$ID_LINE" | awk '{print $2}')"
+ if echo "$KNOWN_IDS" | grep -q "$ID"; then
+ echo "Duplicated ID: $ID"
+ has_error=1
+ else
+ if [ -z "$KNOWN_IDS" ]; then
+ KNOWN_IDS="$ID"
+ else
+ KNOWN_IDS="$KNOWN_IDS:$ID"
+ fi
+ fi
+ else
+ echo "Missing ID for TODO in line $line_n"
+ has_error=1
+ fi
+done
+
+exit "$has_error"