aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/assert-todos.sh
blob: dfa1ab764ea7c7d53416356a4841f289df7a76b5 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
set -eu

if git grep FIXME | grep -v '^TODOs.md' | grep -v '^aux/workflow/assert-todos.sh'; 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 {
	exitstatus = 0
	h2flag = 0
	h2status = ""
	prevline = ""
	idx = 0
	delete ids[0]
}
h2flag == 1 {
	split($0, l, " ")
	timelinestatus = l[2]
	if (h2status != timelinestatus) {
		print "h2/timeline status mismatch for line " NR-1
		print prevline
		print $0
		exitstatus = 1
	}
	h2status = ""
	h2flag = 0
}

/^## (TODO|DOING|WAITING|MEETING|INACTIVE|NEXT|CANCELLED|DONE|WONTFIX)/ {
	if (match($0, / \{#.*?\}.*$/) == 0) {
		print "Missing ID for line " NR ":\n" $0
		exitstatus = 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
		exitstatus = 1
	} else {
		arr[id] = 1
	}

	split($0, l, " ")
	h2status = l[2]
	h2flag = 1
	prevline = $0
}


/^# Scratch$/ {
	exit exitstatus
}
' TODOs.md