Browse code

validate changelog format

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>

Andrew Hsu authored on 2016/12/07 21:23:03
Showing 3 changed files
... ...
@@ -1119,7 +1119,7 @@ that allows to add build-time environment variables (#15182)
1119 1119
 
1120 1120
 - devicemapper: Implement deferred deletion capability (#16381)
1121 1121
 
1122
-## Networking
1122
+### Networking
1123 1123
 
1124 1124
 + `docker network` exits experimental and is part of standard release (#16645)
1125 1125
 + New network top-level concept, with associated subcommands and API (#16645)
1126 1126
new file mode 100755
... ...
@@ -0,0 +1,25 @@
0
+#!/bin/bash
1
+
2
+changelogFile=${1:-CHANGELOG.md}
3
+
4
+if [ ! -r "$changelogFile" ]; then
5
+  echo "Unable to read file $changelogFile" >&2
6
+  exit 1
7
+fi
8
+
9
+changelogWellFormed=1
10
+
11
+# e.g. "## 1.12.3 (2016-10-26)"
12
+VER_LINE_REGEX='^## [0-9]+\.[0-9]+\.[0-9]+ \([0-9]+-[0-9]+-[0-9]+\)$'
13
+while read -r line; do
14
+  if ! [[ "$line" =~ $VER_LINE_REGEX ]]; then
15
+    echo "Malformed changelog $changelogFile line \"$line\"" >&2
16
+    changelogWellFormed=0
17
+  fi
18
+done < <(grep '^## ' $changelogFile)
19
+
20
+if [[ "$changelogWellFormed" == "1" ]]; then
21
+  echo "Congratulations!  Changelog $changelogFile is well-formed."
22
+else
23
+  exit 2
24
+fi
... ...
@@ -14,3 +14,4 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14 14
 . $SCRIPTDIR/test-imports
15 15
 . $SCRIPTDIR/toml
16 16
 . $SCRIPTDIR/vet
17
+. $SCRIPTDIR/changelog-well-formed