aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--aux/assert-catgets.sh67
-rw-r--r--src/gistatic.msg30
3 files changed, 98 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 7aa4730..55d389e 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,7 @@ all: $(manpages) src/gistatic
check: all src/gistatic.t
./src/gistatic.t
+ sh aux/assert-catgets.sh src/gistatic.c
clean:
rm -rf public/ $(manpages) README.*.md CHANGELOG.*.md messages.mo \
diff --git a/aux/assert-catgets.sh b/aux/assert-catgets.sh
new file mode 100644
index 0000000..885e186
--- /dev/null
+++ b/aux/assert-catgets.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+set -eu
+
+assert_sequential_ids() {
+ awk '
+ BEGIN {
+ n = 0
+ }
+
+ /^#define MSG_/ {
+ if (++n != $3) {
+ print "Bad sequential ID:"
+ printf "%s:%s:%s\n", FILENAME, NR, $0
+ printf "expected: %s\ngot: %s\n", n, $3
+ exit 1
+ }
+ }
+ ' "$1"
+}
+
+assert_consistent_msg_definitions() {
+ awk '
+ BEGIN {
+ i = 0
+ j = 0
+ }
+
+ /^#define MSG_/ {
+ defines[i++] = $2
+ }
+
+ /^\t\[MSG_/ {
+ msgs[j++] = substr($0, 3, index($0, "]") - 3)
+ }
+
+ END {
+ for (n in defines) {
+ if (defines[n] != msgs[n]) {
+ printf "Order mismatch between #define"
+ printf " and usage in MSGS[]:\n"
+ printf "#define: %s\nMSGS[]: %s\n",
+ defines[n], msgs[n]
+ exit 1
+ }
+ }
+ }
+ ' "$1"
+}
+
+assert_no_unused_msgs() {
+ DEFINES="$(mktemp)"
+ USAGES="$(mktemp)"
+ awk '/^#define MSG_/ { print $2 }' "$f" | sort > "$DEFINES"
+ awk -F'_\\(' '
+ /_\(MSG_/ { print substr($2, 0, index($2, ")") - 1) }
+ ' "$f" | sort | uniq > "$USAGES"
+ if ! diff "$DEFINES" "$USAGES"; then
+ echo 'Some defined MSG_ items not being used' >&2
+ exit 1
+ fi
+}
+
+for f in "$@"; do
+ assert_sequential_ids "$f"
+ assert_consistent_msg_definitions "$f"
+ assert_no_unused_msgs "$f"
+done
diff --git a/src/gistatic.msg b/src/gistatic.msg
index 2624399..9cf8dc9 100644
--- a/src/gistatic.msg
+++ b/src/gistatic.msg
@@ -19,3 +19,33 @@
9 help: ...
+10 commit feed
+
+11 tags feed
+
+12 files
+
+13 log
+
+14 refs
+
+15 Branch
+
+16 Commit message
+
+17 Author
+
+18 Date
+
+19 Tag
+
+20 Download
+
+21 Missing '-u CLONE_URL'
+
+22 Missing [PATH | [PATHS]]
+
+23 Incompatible options -u and -i
+
+24 Git reference is not direct
+