aboutsummaryrefslogtreecommitdiff
path: root/build-aux/assert-todos.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-01-22 19:24:12 -0300
committerEuAndreh <eu@euandre.org>2021-01-22 19:24:12 -0300
commit768ab333b9e78af6ef1a9b23484e8e9c54c3a8b1 (patch)
tree7e2eb0fa8a51016edbbf52fe7d4609b8707eee58 /build-aux/assert-todos.sh
parentTODOs.md: Add link to Resources section (diff)
downloadserver-768ab333b9e78af6ef1a9b23484e8e9c54c3a8b1.tar.gz
server-768ab333b9e78af6ef1a9b23484e8e9c54c3a8b1.tar.xz
Update shared files under build-aux
Diffstat (limited to 'build-aux/assert-todos.sh')
-rwxr-xr-xbuild-aux/assert-todos.sh55
1 files changed, 25 insertions, 30 deletions
diff --git a/build-aux/assert-todos.sh b/build-aux/assert-todos.sh
index 91015fe..0b0a8d6 100755
--- a/build-aux/assert-todos.sh
+++ b/build-aux/assert-todos.sh
@@ -7,33 +7,28 @@ if git grep FIXME | grep -v '^TODOs.md' | grep -v '^build-aux/assert-todos.sh' |
exit 1
fi
-KNOWN_IDS=''
-has_error=0
-# shellcheck disable=2013
-for todo in $(sed -e '/^\* Tasks$/,/^\* Improvements$/!d' TODOs.md | grep -nE '^\*\* .*$' | cut -d: -f1); do
- if sed "${todo}q;d" TODOs.md | 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.md)"
- 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"
+awk -F'{#' '
+BEGIN {
+ status=0
+ idx=0
+ delete ids[0]
+}
+/^## / {
+ if (match($0, / \{#.*?\}$/) == 0) {
+ print "Missing ID for line " NR ":\n" $0
+ status=1
+ }
+ id_with_prefix = substr($2, 0, length($2) - 1)
+ match(id_with_prefix, /^\w+-/)
+ id = substr(id_with_prefix, RLENGTH + 1)
+ if (id in arr) {
+ print "Duplicate ID: " id
+ status=1
+ } else {
+ arr[id] = 1
+ }
+}
+/^# Improvements$/ {
+ exit status
+}
+' TODOs.md