@@ -24,7 +24,7 @@ PR_NUMBER, GITHUB_REPOSITORY, GITHUB_TOKEN. The script is intended
2424for automated execution from GitHub Actions workflow."
2525
2626declare -ar LABELS=(
27- " Size : XS"
27+ " size : XS"
2828 " size: S"
2929 " size: M"
3030 " size: L"
@@ -39,14 +39,6 @@ declare -A LIMITS=(
3939 [" ${LABELS[4]} " ]=" $(( 2 ** 63 - 1 )) "
4040)
4141
42- declare -ar IGNORED=(
43- " *_pb2.py"
44- " *_pb2.pyi"
45- " *_pb2_grpc.py"
46- " .*.lock"
47- " *.bundle.js"
48- )
49-
5042function info() {
5143 echo >&2 " INFO: ${* } "
5244}
@@ -110,30 +102,20 @@ function api_call() {
110102
111103function compute_changes() {
112104 local -r pr=" $1 "
105+ local page=1
106+ local changes=0
107+ while true ; do
108+ local response
109+ response=" $( api_call " pulls/${pr} /files?per_page=100&page=${page} " ) "
110+
111+ if [[ " $( jq_stdin ' length' <<< " ${response}" ) " -eq 0 ]]; then
112+ break
113+ fi
113114
114- local response
115- local change_info
116- local -r keys_filter=' with_entries(select([.key] | inside(["changes", "filename"])))'
117- response=" $( api_call " pulls/${pr} /files" ) "
118- change_info=" $( jq_stdin " map(${keys_filter} )" <<< " ${response}" ) "
119-
120- local files total_changes
121- readarray -t files < <( jq_stdin -c ' .[]' <<< " ${change_info}" )
122- total_changes=0
123- for file in " ${files[@]} " ; do
124- local name changes
125- name=" $( jq_stdin -r ' .filename' <<< " ${file}" ) "
126- for pattern in " ${IGNORED[@]} " ; do
127- if [[ " $name " =~ ${pattern} ]]; then
128- info " File $name ignored"
129- continue 2
130- fi
131- done
132- changes=" $( jq_stdin -r ' .changes' <<< " ${file}" ) "
133- info " File $name +-$changes "
134- total_changes=" $(( total_changes + changes)) "
115+ changes=$(( changes + $(jq_stdin '[0 , .[].changes] | add' <<< "${response} ")) )
116+ (( page++ ))
135117 done
136- echo " $total_changes "
118+ echo " ${changes} "
137119}
138120
139121function get_size_label() {
0 commit comments