Browse code

Merge pull request #29208 from andrewhsu/validate-changelog

validate CHANGELOG.md is well-formed
(cherry picked from commit 59ba895a0f610f5bf34ef6748540af1509910bea)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Vincent Demeester authored on 2016/12/13 01:59:41
Showing 3 changed files
... ...
@@ -1473,7 +1473,7 @@ that allows to add build-time environment variables (#15182)
1473 1473
 
1474 1474
 - devicemapper: Implement deferred deletion capability (#16381)
1475 1475
 
1476
-## Networking
1476
+### Networking
1477 1477
 
1478 1478
 + `docker network` exits experimental and is part of standard release (#16645)
1479 1479
 + New network top-level concept, with associated subcommands and API (#16645)
1480 1480
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