@cryptotaxi247 / kubo / commits / d3604bb06

feat: improve mkreleaslog

1. Allow matching the entire module instead of just github orgs/usernames. 2. Allow excluding some modules. 3. Ignore files using a github pathspec and apply the same ignore patterns to the "contributors" section.

Steven Allen committed Jul 21, 2021 at 10:54 UTC d3604bb06a62c8419ed8f43ea8839294cb1289ea
1 file changed +73 -27
bin/mkreleaselog
+73 -27
@@ -1,40 +1,75 @@
1 #!/bin/zsh
2 -#set -x
2 set -euo pipefail
3 export GO111MODULE=on
4 export GOPATH="$(go env GOPATH)"
5
7 -alias jq="jq --unbuffered"
8 -
9 -AUTHORS=(
6 +# List of PCRE regular expressions to match "included" modules.
7 +INCLUDE_MODULES=(
8 # orgs
11 - ipfs
12 - ipld
13 - libp2p
14 - multiformats
15 - filecoin-project
16 - ipfs-shipyard
17 -
18 - # Authors of personal repos used by go-ipfs that should be mentioned in the
9 + "^github.com/ipfs/"
10 + "^github.com/ipld/"
11 + "^github.com/libp2p/"
12 + "^github.com/multiformats/"
13 + "^github.com/filecoin-project/"
14 + "^github.com/ipfs-shipyard/"
15 +
16 + # Authors of personal modules used by go-ipfs that should be mentioned in the
17 # release notes.
20 - whyrusleeping
21 - Kubuxu
22 - jbenet
23 - Stebalien
24 - marten-seemann
25 - hsanjuan
26 - lucas-clemente
27 - warpfork
18 + "^github.com/whyrusleeping/"
19 + "^github.com/Kubuxu/"
20 + "^github.com/jbenet/"
21 + "^github.com/Stebalien/"
22 + "^github.com/marten-seemann/"
23 + "^github.com/hsanjuan/"
24 + "^github.com/lucas-clemente/"
25 + "^github.com/warpfork/"
26 +)
27 +
28 +# List of PCRE regular expressions to match "excluded" modules. Applied after includes.
29 +EXCLUDE_MODULES=(
30 + "^github.com/marten-seemann/qtls"
31 )
32
30 -[[ -n "${REPO_FILTER+x}" ]] || REPO_FILTER="github.com/(${$(printf "|%s" "${AUTHORS[@]}"):1})"
33 +# Ignored files as git pathspecs.
34 +IGNORE_FILES=(
35 + ".gx"
36 + "package.json"
37 + ".travis.yml"
38 + "go.mod"
39 + "go.sum"
40 + ".github"
41 + ".circleci"
42 + "*.pb.go"
43 + "cbor_gen.go"
44 + "ipldsch_*.go"
45 +)
46 +
47 +##########################################################################################
48 +
49 +if [[ ${#INCLUDE_MODULES[@]} -gt 0 ]]; then
50 + INCLUDE_REGEX="(${$(printf "|%s" "${INCLUDE_MODULES[@]}"):1})"
51 +else
52 + INCLUDE_REGEX="" # "match anything"
53 +fi
54 +
55 +if [[ ${#EXCLUDE_MODULES[@]} -gt 0 ]]; then
56 + EXCLUDE_REGEX="(${$(printf "|%s" "${EXCLUDE_MODULES[@]}"):1})"
57 +else
58 + EXCLUDE_REGEX='$^' # "match nothing"
59 +fi
60 +
61 +IGNORE_FILES_PATHSPEC=()
62 +for f in "${IGNORE_FILES[@]}"; do
63 + IGNORE_FILES_PATHSPEC+=(":^:$f") # Prepend the magic "ignore this" sequence.
64 +done
65
32 -[[ -n "${IGNORED_FILES+x}" ]] || IGNORED_FILES='^\(\.gx\|package\.json\|\.travis\.yml\|go\.mod\|go\.sum\|\.github\|\.circleci\|.*\.pb\.go\|cbor_gen\.go\|.*ipldsch.*\.go\)$'
66
67 NL=$'\n'
68
69 ROOT_DIR="$(git rev-parse --show-toplevel)"
70
71 +alias jq="jq --unbuffered"
72 +
73 msg() {
74 echo "$*" >&2
75 }
@@ -50,7 +85,7 @@ statlog() {
85 fi
86
87 local stack=()
53 - git -C "$rpath" -c mailmap.file="$mailmap_file" log --use-mailmap --shortstat --no-merges --pretty="tformat:%H%x09%aN%x09%aE" "$start..$end" -- . ':^*\.pb\.go' ':^*ipldsch*\.go' ':^cbor_gen\.go\' ':^go\.mod' ':^go\.sum' | while read -r line; do
88 + git -C "$rpath" -c mailmap.file="$mailmap_file" log --use-mailmap --shortstat --no-merges --pretty="tformat:%H%x09%aN%x09%aE" "$start..$end" -- . "${IGNORE_FILES_PATHSPEC[@]}" | while read -r line; do
89 if [[ -n "$line" ]]; then
90 stack+=("$line")
91 continue
@@ -109,6 +144,17 @@ pr_link() {
144 printf -- "[%s#%s](https://%s/pull/%s)" "$ghname" "$prnum" "$repo" "$prnum"
145 }
146
147 +ignored_commit() {
148 + local commit="$1"
149 + local matches
150 +
151 + # Check to see if this commit includes any non-ignored files.
152 + # Use jq instead of grep so we get PCRE regexes.
153 + matches=$(git -C "$dir" diff-tree --no-commit-id --name-only -r "$commit" \
154 + -- "${IGNORE_FILES_PATHSPEC[@]}" | wc -l)
155 + [[ "$matches" -eq 0 ]]
156 +}
157 +
158 # Generate a release log for a range of commits in a single repo.
159 release_log() {
160 setopt local_options BASH_REMATCH
@@ -125,9 +171,8 @@ release_log() {
171 --first-parent \
172 "$start..$end" |
173 while read commit subject; do
128 - # Skip gx-only PRs.
129 - if git rev-parse '$commit^' >/dev/null 2>&1 &&
130 - ! git -C "$dir" diff-tree --no-commit-id --name-only "$commit^" "$commit" | grep -v "${IGNORED_FILES}" >/dev/null; then
174 + # Skip commits that only touch ignored files.
175 + if ignored_commit "$commit"; then
176 continue
177 fi
178
@@ -219,7 +264,8 @@ recursive_release_log() {
264 statlog "$module" "$start" "$end" > statlog.json
265
266 dep_changes old_deps.json new_deps.json |
222 - jq --arg filter "$REPO_FILTER" 'select(.Path | match($filter))' |
267 + jq --arg inc "$INCLUDE_REGEX" --arg exc "$EXCLUDE_REGEX" \
268 + 'select(.Path | test($inc)) | select(.Path | test($exc) | not)' |
269 # Compute changelogs
270 jq -r '"\(.Path) \(.New.Version) \(.New.Ref) \(.Old.Version) \(.Old.Ref // "")"' |
271 while read module new new_ref old old_ref; do