@@ -17,19 +17,34 @@ if ! ("$awk_exe" --version | grep GNU) >/dev/null 2>&1; then
1717 exit 1
1818fi
1919
20- if ! [[ " $1 " =~ ^M[0-9]+[a-z]? $ ]] ; then
21- echo " Version tag must be of the form 'M4' or 'M4a'. E.g."
22- echo " $0 M4a"
20+ input_version=" $1 "
21+
22+ if ! [[ " $input_version " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]] ; then
23+ echo " Version tag must be of the form 'x.y.z' where x, y, and z are nonnegative integers. e.g."
24+ echo " $0 0.5.11"
2325 exit 1
2426fi
2527
26- echo " $1 " | $awk_exe '
27- # This script figures out a previous tag for a given release to make release notes from.
28+ if [[ " $input_version " == " 0.5.11" ]]; then
29+ echo " M5j"
30+ else
31+ IFS=' .' read -r -a version_parts <<< " $input_version"
32+ major=${version_parts[0]}
33+ minor=${version_parts[1]}
34+ patch=${version_parts[2]}
2835
29- # The previous release of something like M4a is just M4
30- match($0, /^(\w[0-9]+)a$/, a) {print a[1]}
31- # The previous release of something like M4 is M3, since we want to show off everything since the last major release
32- match($0, /^\w([0-9]+)$/, a) {print "M" a[1] - 1}
33- # The previous release of something like M4b is M4a
34- match($0, /^(\w[0-9]+)([b-z])$/, a) {printf a[1]; system("echo " a[2] " | tr b-z a-y")}
35- '
36+ if [[ " $patch " -gt 0 ]]; then
37+ patch=$(( patch - 1 ))
38+ echo " $major .$minor .$patch "
39+ elif [[ " $minor " -gt 0 ]]; then
40+ minor=$(( minor - 1 ))
41+ tag=$( git tag --list " release/$major .$minor .*" | sort -r | head -n 1)
42+ echo " ${tag# release/ } "
43+ elif [[ " $major " -gt 0 ]]; then
44+ major=$(( major - 1 ))
45+ tag=$( git tag --list " release/$major .*" | sort -r | head -n 1)
46+ echo " ${tag# release/ } "
47+ else
48+ echo " Idk what to do with $input_version " .
49+ fi
50+ fi
0 commit comments