fix(mkreleasenotes): include commits directly to master
This will include: * Commits to master. * Squashed merges. In the release notes.
Steven Allen committed
May 8, 2020 at 19:37 UTC
d2b1d5b7d4bfaca2f1365499b52e8163308a9947
1 file changed
+22
-7
bin/mkreleaselog
+22
-7
@@ -88,27 +88,42 @@ resolve_commits() {
88
jq '. + {Ref: (.Version|capture("^((?<ref1>.*)\\+incompatible|v.*-(0\\.)?[0-9]{14}-(?<ref2>[a-f0-9]{12})|(?<ref3>v.*))$") | .ref1 // .ref2 // .ref3)}'
89
}
90
91
+pr_link() {
92
+ local repo="$1"
93
+ local prnum="$2"
94
+ local ghname="${repo##github.com/}"
95
+ printf -- "[%s#%s](https://%s/pull/%s)" "$ghname" "$prnum" "$repo" "$prnum"
96
+}
97
+
98
# Generate a release log for a range of commits in a single repo.
99
release_log() {
100
+ setopt local_options BASH_REMATCH
101
+
102
local repo="$1"
103
local start="$2"
104
local end="${3:-HEAD}"
96
- local ghname="${repo##github.com/}"
105
local dir="$GOPATH/src/$repo"
106
99
- local commit prnum
107
+ local commit pr
108
git -C "$dir" log \
109
--format='tformat:%H %s' \
102
- --merges \
110
+ --first-parent \
111
"$start..$end" |
104
- sed -n -e 's/\([a-f0-9]\+\) .*#\([0-9]\+\).*/\1 \2/p' |
105
- while read commit prnum; do
112
+ while read commit subject; do
113
# Skip gx-only PRs.
114
git -C "$dir" diff-tree --no-commit-id --name-only "$commit^" "$commit" |
115
grep -v "${IGNORED_FILES}" >/dev/null || continue
116
110
- local desc="$(git -C "$dir" show --summary --format='tformat:%b' "$commit" | head -1)"
111
- printf -- "- %s ([%s#%s](https://%s/pull/%s))\n" "$desc" "$ghname" "$prnum" "$repo" "$prnum"
117
+ if [[ "$subject" =~ '^Merge pull request #([0-9]+) from' ]]; then
118
+ local prnum="${BASH_REMATCH[2]}"
119
+ local desc="$(git -C "$dir" show --summary --format='tformat:%b' "$commit" | head -1)"
120
+ printf -- "- %s (%s)\n" "$desc" "$(pr_link "$repo" "$prnum")"
121
+ elif [[ "$subject" =~ '\(#([0-9]+)\)$' ]]; then
122
+ local prnum="${BASH_REMATCH[2]}"
123
+ printf -- "- %s (%s)\n" "$subject" "$(pr_link "$repo" "$prnum")"
124
+ else
125
+ printf -- "- %s\n" "$subject"
126
+ fi
127
done
128
}
129