aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-01-10 10:35:48 -0300
committerEuAndreh <eu@euandre.org>2021-01-10 10:42:06 -0300
commitf0c75e1433d0c91729d2fb3814c9fdac4bf42ffd (patch)
tree679b86c09d3a1bbc5c8a5c1dccde69467af0f947
parentMove workflow/ to build-aux/workflow/ (diff)
downloadserver-f0c75e1433d0c91729d2fb3814c9fdac4bf42ffd.tar.gz
server-f0c75e1433d0c91729d2fb3814c9fdac4bf42ffd.tar.xz
Readd assert-todos.sh
-rw-r--r--Makefile2
-rwxr-xr-xbuild-aux/assert-todos.sh38
2 files changed, 39 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 7238cf3..54c7468 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
.PHONY: check
check:
./build-aux/assert-shellcheck.sh
- # ./build-aux/assert-todos.sh
+ ./build-aux/assert-todos.sh
./build-aux/assert-terraform.sh
.PHONY: clean
diff --git a/build-aux/assert-todos.sh b/build-aux/assert-todos.sh
new file mode 100755
index 0000000..3fe513a
--- /dev/null
+++ b/build-aux/assert-todos.sh
@@ -0,0 +1,38 @@
+#!/bin/sh -eu
+
+if git grep FIXME | grep -v '^TODOs.org' | grep -v '^build-aux/assert-todos.sh' | grep -v '^build-aux/docbook-xsl/'; 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"