aboutsummaryrefslogtreecommitdiff
path: root/build-aux/assert-todos.sh
blob: 0b0a8d6bdfc6b215ddffa4a77d9e2647f8f8f119 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
set -eu

if git grep FIXME | grep -v '^TODOs.md' | 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.md."
  exit 1
fi

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