5353
5454DRY_RUN=false
5555LOCAL_ONLY=false
56+ INCLUDE_PR_COMMITS=false
5657
5758while [[ $# -gt 0 ]]; do
5859 case " $1 " in
@@ -151,28 +152,9 @@ if ! echo "$raw_prs" | jq empty >/dev/null 2>&1; then
151152 echo " $raw_prs "
152153 exit 1
153154fi
154-
155155mapfile -t all_prs < <( echo " $raw_prs " | jq -c ' .[]' )
156156echo " ℹ️ Retrieved ${# all_prs[@]} PRs"
157157
158- matched_prs=()
159- pr_commit_shas=()
160- for pr in " ${all_prs[@]} " ; do
161- merged_at=$( echo " $pr " | jq -r ' .merged_at' )
162- [[ " $merged_at " == " null" ]] && continue
163-
164- pr_number=$( echo " $pr " | jq -r ' .number' )
165- pr_commits=$( gh api " /repos/$repo /pulls/$pr_number /commits" | jq -r ' .[].sha' )
166-
167- for sha in $pr_commits ; do
168- if [[ " ${all_commit_shas[*]} " =~ " $sha " ]]; then
169- matched_prs+=(" $pr " )
170- pr_commit_shas+=($pr_commits )
171- break
172- fi
173- done
174- done
175-
176158features=()
177159fixes=()
178160breaking=()
@@ -192,7 +174,24 @@ classify() {
192174 fi
193175}
194176
195- for pr_json in " ${matched_prs[@]} " ; do
177+ matched_prs=()
178+ pr_commit_shas=()
179+ for pr_json in " ${all_prs[@]} " ; do
180+ merged_at=$( echo " $pr_json " | jq -r ' .merged_at' )
181+ [[ " $merged_at " == " null" ]] && continue
182+
183+ pr_number=$( echo " $pr_json " | jq -r ' .number' )
184+ mapfile -t pr_commits < <( gh api " /repos/$repo /pulls/$pr_number /commits" | jq -r ' .[].sha' )
185+
186+ pr_matches_range=false
187+ for sha in " ${pr_commits[@]} " ; do
188+ if [[ " ${all_commit_shas[*]} " =~ " $sha " ]]; then
189+ pr_matches_range=true
190+ break
191+ fi
192+ done
193+ [[ " $pr_matches_range " == false ]] && continue
194+
196195 title=$( echo " $pr_json " | jq -r ' .title' )
197196 number=$( echo " $pr_json " | jq -r ' .number' )
198197 author=$( echo " $pr_json " | jq -r ' .user.login' )
@@ -202,9 +201,27 @@ for pr_json in "${matched_prs[@]}"; do
202201 continue
203202 fi
204203
204+ matched_prs+=(" $pr_json " )
205+ pr_commit_shas+=(" ${pr_commits[@]} " )
206+
205207 line=" * $title ([#${number} ](https://github.com/$repo /pull/${number} )) by [@$author ](https://github.com/$author )"
206208 classify " $title " " $line "
207209 contributors+=(" $author " )
210+
211+ if [[ " ${INCLUDE_PR_COMMITS:- true} " == true ]]; then
212+ for sha in " ${pr_commits[@]} " ; do
213+ if [[ " ${all_commit_shas[*]} " =~ " $sha " ]]; then
214+ msg=$( git show -s --format=" %s" " $sha " )
215+ if should_ignore " $msg " ; then continue ; fi
216+ commit_author=$( gh api " /repos/$repo /commits/$sha " --jq ' .author.login' 2> /dev/null || echo " " )
217+ author_name=${commit_author:- $(git show -s --format=" %an" " $sha " )}
218+ short_sha=$( git rev-parse --short " $sha " )
219+ subline=" * [#${number} ] $msg ([${short_sha} ](https://github.com/$repo /commit/$sha )) by [@$author_name ](https://github.com/$author_name )"
220+ classify " $msg " " $subline "
221+ contributors+=(" $author_name " )
222+ fi
223+ done
224+ fi
208225done
209226
210227for sha in " ${all_commit_shas[@]} " ; do
@@ -343,4 +360,4 @@ if [[ "$LOCAL_ONLY" == false ]]; then
343360 fi
344361fi
345362
346- echo " 🎉 Done."
363+ echo " 🎉 Done."
0 commit comments