Browse code

Merge pull request #31271 from thaJeztah/cherry-pick-changelog-validation

[17.03] Cherry pick changelog validation

Victor Vieux authored on 2017/02/23 12:38:05
Showing 4 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,12 @@
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
+grep -e '^## ' "$changelogFile" | awk '{print$3}' | sort -c -r || exit 2
10
+
11
+echo "Congratulations!  Changelog $changelogFile dates are in descending order."
0 12
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]+(-ce)? \([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,5 @@ 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
18
+. $SCRIPTDIR/changelog-date-descending