@@ -32,7 +32,7 @@ range="$from_ref..$to_ref"
32
32
dependencies gh
33
33
34
34
COMMIT_METADATA_BREAKING=0
35
- declare -A COMMIT_METADATA_TITLE COMMIT_METADATA_CATEGORY
35
+ declare -A COMMIT_METADATA_TITLE COMMIT_METADATA_CATEGORY COMMIT_METADATA_AUTHORS
36
36
37
37
# This environment variable can be set to 1 to ignore missing commit metadata,
38
38
# useful for dry-runs.
@@ -66,22 +66,26 @@ main() {
66
66
#
67
67
# Example output:
68
68
#
69
- # 27386d49d08455b6f8fbf2c18f38244d03fda892 label:security
70
- # d9f2aaf3b430d8b6f3d5f24032ed6357adaab1f1
71
- # fd54512858c906e66f04b0744d8715c2e0de97e6 label:stale label:enhancement
69
+ # 27386d49d08455b6f8fbf2c18f38244d03fda892 author:hello labels:label:security
70
+ # d9f2aaf3b430d8b6f3d5f24032ed6357adaab1f1 author:world
71
+ # fd54512858c906e66f04b0744d8715c2e0de97e6 author:bye labels:label:stale label:enhancement
72
+ from_commit_date=2023-01-18
72
73
mapfile -t pr_labels_raw < <(
73
74
gh pr list \
74
75
--base main \
75
76
--state merged \
76
77
--limit 10000 \
77
78
--search " merged:>=$from_commit_date " \
78
- --json mergeCommit,labels \
79
- --jq ' .[] | .mergeCommit.oid + " " + (["label:" + .labels[].name] | join(" "))'
79
+ --json mergeCommit,labels,author \
80
+ --jq ' .[] | "\( .mergeCommit.oid ) author:\( .author.login ) labels:\ (["label:\( .labels[].name )" ] | join(" "))" '
80
81
)
81
- declare -A labels
82
+ declare -A authors labels
82
83
for entry in " ${pr_labels_raw[@]} " ; do
83
84
commit_sha_long=${entry%% * }
84
- all_labels=${entry#* }
85
+ commit_author=${entry#* author: }
86
+ commit_author=${commit_author%% * }
87
+ authors[$commit_sha_long ]=$commit_author
88
+ all_labels=${entry#* labels: }
85
89
labels[$commit_sha_long ]=$all_labels
86
90
done
87
91
@@ -92,7 +96,7 @@ main() {
92
96
commit_prefix=${parts[2]}
93
97
94
98
# Safety-check, guarantee all commits had their metadata fetched.
95
- if [[ ! -v labels[$commit_sha_long ] ]]; then
99
+ if [[ ! -v authors[ $commit_sha_long ] ]] || [[ ! -v labels[$commit_sha_long ] ]]; then
96
100
if [[ $ignore_missing_metadata != 1 ]]; then
97
101
error " Metadata missing for commit $commit_sha_short "
98
102
else
@@ -104,6 +108,9 @@ main() {
104
108
title=${parts[*]: 2}
105
109
title=${title% $' \n ' }
106
110
COMMIT_METADATA_TITLE[$commit_sha_short ]=$title
111
+ if [[ -v authors[$commit_sha_long ] ]]; then
112
+ COMMIT_METADATA_AUTHORS[$commit_sha_short ]=" @${authors[$commit_sha_long]} "
113
+ fi
107
114
108
115
# First, check the title for breaking changes. This avoids doing a
109
116
# GH API request if there's a match.
@@ -132,12 +139,12 @@ main() {
132
139
}
133
140
134
141
declare_print_commit_metadata () {
135
- declare -p COMMIT_METADATA_BREAKING COMMIT_METADATA_TITLE COMMIT_METADATA_CATEGORY
142
+ declare -p COMMIT_METADATA_BREAKING COMMIT_METADATA_TITLE COMMIT_METADATA_CATEGORY COMMIT_METADATA_AUTHORS
136
143
}
137
144
138
145
export_commit_metadata () {
139
146
_COMMIT_METADATA_CACHE=" ${range} :$( declare_print_commit_metadata) "
140
- export _COMMIT_METADATA_CACHE COMMIT_METADATA_BREAKING COMMIT_METADATA_TITLE COMMIT_METADATA_CATEGORY
147
+ export _COMMIT_METADATA_CACHE COMMIT_METADATA_BREAKING COMMIT_METADATA_TITLE COMMIT_METADATA_CATEGORY COMMIT_METADATA_AUTHORS
141
148
}
142
149
143
150
# _COMMIT_METADATA_CACHE is used to cache the results of this script in
0 commit comments