fix(mkreleaselog): support multiple commit authors
This will output one entry per commit author in the "stat" log, instead of just crashing.
Steven Allen committed
Jun 23, 2021 at 15:04 UTC
4be04bce4e2a863b6124673753aabc745dea0233
1 file changed
+21
-15
bin/mkreleaselog
+21
-15
@@ -49,13 +49,15 @@ statlog() {
49
mailmap_file="$ROOT_DIR/.mailmap"
50
fi
51
52
- git -C "$rpath" -c mailmap.file="$mailmap_file" log --use-mailmap --shortstat --no-merges --pretty="tformat:%H%n%aN%n%aE" "$start..$end" -- . ':^*\.pb\.go' ':^*ipldsch*\.go' ':^cbor_gen\.go\' ':^go\.mod' ':^go\.sum' | while
53
- read hash
54
- read name
55
- read email
56
- read _ # empty line
57
- read changes
58
- do
52
+ 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
54
+ if [[ -n "$line" ]]; then
55
+ stack+=("$line")
56
+ continue
57
+ fi
58
+
59
+ read -r changes
60
+
61
changed=0
62
insertions=0
63
deletions=0
@@ -72,14 +74,18 @@ statlog() {
74
fi
75
done<<<"${changes//,/$NL}"
76
75
- jq -n \
76
- --arg "hash" "$hash" \
77
- --arg "name" "$name" \
78
- --arg "email" "$email" \
79
- --argjson "changed" "$changed" \
80
- --argjson "insertions" "$insertions" \
81
- --argjson "deletions" "$deletions" \
82
- '{Commit: $hash, Author: $name, Email: $email, Files: $changed, Insertions: $insertions, Deletions: $deletions}'
77
+ for author in "${stack[@]}"; do
78
+ IFS=$'\t' read -r hash name email <<<"$author"
79
+ jq -n \
80
+ --arg "hash" "$hash" \
81
+ --arg "name" "$name" \
82
+ --arg "email" "$email" \
83
+ --argjson "changed" "$changed" \
84
+ --argjson "insertions" "$insertions" \
85
+ --argjson "deletions" "$deletions" \
86
+ '{Commit: $hash, Author: $name, Email: $email, Files: $changed, Insertions: $insertions, Deletions: $deletions}'
87
+ done
88
+ stack=()
89
done
90
}
91