Skip to content

Commit 7289cab

Browse files
committed
Further simplify compute_changes() and remove IGNORED
1 parent a6a494b commit 7289cab

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

dev_tools/ci/size-labeler.sh

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
5042
function info() {
5143
echo >&2 "INFO: ${*}"
5244
}
@@ -111,30 +103,19 @@ function api_call() {
111103
function compute_changes() {
112104
local -r pr="$1"
113105
local page=1
114-
local total_changes=0
106+
local changes=0
115107
while true; do
116108
local response
117109
response="$(api_call "pulls/${pr}/files?per_page=100&page=${page}")"
118110

119-
if [[ "$(jq_stdin '. | length' <<<"${response}")" -eq 0 ]]; then
111+
if [[ "$(jq_stdin 'length' <<<"${response}")" -eq 0 ]]; then
120112
break
121113
fi
122114

123-
local name changes
124-
while IFS= read -r name && IFS= read -r changes; do
125-
for pattern in "${IGNORED[@]}"; do
126-
# shellcheck disable=SC2053 # Need leave the pattern unquoted.
127-
if [[ "${name}" == ${pattern} ]]; then
128-
info "File ${name} ignored"
129-
continue 2
130-
fi
131-
done
132-
info "File ${name} +-${changes}"
133-
total_changes="$((total_changes + changes))"
134-
done < <(jq_stdin -r '.[] | .filename, .changes' <<<"${response}")
115+
changes=$((changes + $(jq_stdin '[0, .[].changes] | add' <<<"${response}")))
135116
((page++))
136117
done
137-
echo "${total_changes}"
118+
echo "${changes}"
138119
}
139120

140121
function get_size_label() {

0 commit comments

Comments
 (0)