fix: allow multiples files to ignore (#39)

This commit is contained in:
Rafa Gómez 2022-04-07 21:38:33 +02:00 committed by GitHub
parent 88ab4d8199
commit 54ef36785e
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -48,9 +48,9 @@ jobs:
xl_label: 'size/xl'
fail_if_xl: 'false'
message_if_xl: >
'This PR exceeds the recommended size of 1000 lines.
This PR exceeds the recommended size of 1000 lines.
Please make sure you are NOT addressing multiple issues with one PR.
Note this PR might be rejected due to its size.
Note this PR might be rejected due to its size.
github_api_url: 'api.github.com'
files_to_ignore: ''
```

View file

@ -17,13 +17,17 @@ github::calculate_total_modifications() {
local -r body=$(curl -sSL -H "Authorization: token $GITHUB_TOKEN" -H "$GITHUB_API_HEADER" "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/$pr_number/files?per_page=100")
local changes=0
for file in $(echo "$body" | jq -r '.[] | @base64'); do
local ignore_file=0
for file_to_ignore in $files_to_ignore; do
if [ "$file_to_ignore" != "$(basename $(jq::base64 '.filename'))" ]; then
total_changes=$(jq::base64 '.changes')
((changes += total_changes))
if [ "$file_to_ignore" = "$(basename $(jq::base64 '.filename'))" ]; then
ignore_file=1
fi
done
if [ $ignore_file -eq 0 ]; then
((changes += $(jq::base64 '.changes')))
fi
done
echo $changes