Skip to content

Commit c6dc97a

Browse files
committed
Rename config variable to be ignore_line_deletions
1 parent 8e7d171 commit c6dc97a

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,23 @@ jobs:
5555
5656
## 🎛️ Arguments
5757
58-
| Name | Required | Default Value | Description |
59-
|-------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------|
60-
| `GITHUB_TOKEN` | Yes | Automatically supplied| GitHub token needed to interact with the repository. |
61-
| `xs_label` | No | 'size/xs' | Label for very small-sized PRs. |
62-
| `xs_max_size` | No | '10' | Maximum number of changes allowed for XS-sized PRs. |
63-
| `s_label` | No | 'size/s' | Label for small-sized PRs. |
64-
| `s_max_size` | No | '100' | Maximum number of changes allowed for S-sized PRs. |
65-
| `m_label` | No | 'size/m' | Label for medium-sized PRs. |
66-
| `m_max_size` | No | '500' | Maximum number of changes allowed for M-sized PRs. |
67-
| `l_label` | No | 'size/l' | Label for large-sized PRs. |
68-
| `l_max_size` | No | '1000' | Maximum number of changes allowed for L-sized PRs. |
69-
| `xl_label` | No | 'size/xl' | Label for extra-large-sized PRs. |
70-
| `fail_if_xl` | No | 'false' | Whether to fail the GitHub workflow if the PR size is 'XL' (blocks the merge). |
71-
| `message_if_xl` | No | Custom message | Message to display when a PR exceeds the 'XL' size limit. |
72-
| `github_api_url` | No | 'https://api.github.com' | URL for the GitHub API, can be changed for GitHub Enterprise Servers. |
73-
| `files_to_ignore` | No | '' | Files to ignore during PR size calculation. Supports newline or whitespace delimited list. |
58+
| Name | Required | Default Value | Description |
59+
|-------------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------|
60+
| `GITHUB_TOKEN` | Yes | Automatically supplied| GitHub token needed to interact with the repository. |
61+
| `xs_label` | No | 'size/xs' | Label for very small-sized PRs. |
62+
| `xs_max_size` | No | '10' | Maximum number of changes allowed for XS-sized PRs. |
63+
| `s_label` | No | 'size/s' | Label for small-sized PRs. |
64+
| `s_max_size` | No | '100' | Maximum number of changes allowed for S-sized PRs. |
65+
| `m_label` | No | 'size/m' | Label for medium-sized PRs. |
66+
| `m_max_size` | No | '500' | Maximum number of changes allowed for M-sized PRs. |
67+
| `l_label` | No | 'size/l' | Label for large-sized PRs. |
68+
| `l_max_size` | No | '1000' | Maximum number of changes allowed for L-sized PRs. |
69+
| `xl_label` | No | 'size/xl' | Label for extra-large-sized PRs. |
70+
| `fail_if_xl` | No | 'false' | Whether to fail the GitHub workflow if the PR size is 'XL' (blocks the merge). |
71+
| `message_if_xl` | No | Custom message | Message to display when a PR exceeds the 'XL' size limit. |
72+
| `github_api_url` | No | 'https://api.github.com' | URL for the GitHub API, can be changed for GitHub Enterprise Servers. |
73+
| `files_to_ignore` | No | '' | Files to ignore during PR size calculation. Supports newline or whitespace delimited list. |
74+
| `ignore_line_deletions` | No | 'false' | Whether to ignore lines which are deleted when calculating the PR size. If set to 'true', deleted lines will be ignored. |
7475

7576
### Example for `files_to_ignore`:
7677
```yml

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ inputs:
5959
description: 'Whitespace separated list of files to ignore when calculating the PR size (sum of changes)'
6060
required: false
6161
default: ''
62-
ignore_file_deletions:
62+
ignore_line_deletions:
6363
description: 'Ignore lines that are deleted, thereby only considering additions.'
6464
required: false
6565
default: 'false'
@@ -81,7 +81,7 @@ runs:
8181
- --fail_if_xl=${{ inputs.fail_if_xl }}
8282
- --message_if_xl="${{ inputs.message_if_xl }}"
8383
- --files_to_ignore=${{ inputs.files_to_ignore }}
84-
- --ignore_file_deletions=${{ inputs.ignore_file_deletions }}
84+
- --ignore_line_deletions=${{ inputs.ignore_line_deletions }}
8585
branding:
8686
icon: 'tag'
8787
color: 'green'

src/github.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GITHUB_API_HEADER="Accept: application/vnd.github.v3+json"
55
github::calculate_total_modifications() {
66
local -r pr_number="${1}"
77
local -r files_to_ignore="${2}"
8-
local -r ignore_file_deletions="${3}"
8+
local -r ignore_line_deletions="${3}"
99

1010
local additions=0
1111
local deletions=0
@@ -15,7 +15,7 @@ github::calculate_total_modifications() {
1515

1616
additions=$(echo "$body" | jq '.additions')
1717

18-
if [ "$ignore_file_deletions" != "true" ]; then
18+
if [ "$ignore_line_deletions" != "true" ]; then
1919
((deletions += $(echo "$body" | jq '.deletions')))
2020
fi
2121
else
@@ -40,7 +40,7 @@ github::calculate_total_modifications() {
4040
if [ "$ignore" = false ]; then
4141
((additions += $(_jq '.additions')))
4242

43-
if [ "$ignore_file_deletions" != "true" ]; then
43+
if [ "$ignore_line_deletions" != "true" ]; then
4444
((deletions += $(_jq '.deletions')))
4545
fi
4646
fi

src/labeler.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ labeler::label() {
99
local -r fail_if_xl="${10}"
1010
local -r message_if_xl="${11}"
1111
local -r files_to_ignore="${12}"
12-
local -r ignore_file_deletions="${13}"
12+
local -r ignore_line_deletions="${13}"
1313

1414
local -r pr_number=$(github_actions::get_pr_number)
15-
local -r total_modifications=$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}" "$ignore_file_deletions")
15+
local -r total_modifications=$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}" "$ignore_line_deletions")
1616

1717
log::message "Total modifications (additions + deletions): $total_modifications"
1818
log::message "Ignoring files (if present): $files_to_ignore"

src/main.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ source "$PR_SIZE_LABELER_HOME/src/misc.sh"
99
##? Adds a size label to a GitHub Pull Request
1010
##?
1111
##? Usage:
12-
##? main.sh --github_token=<token> --xs_label=<label> --xs_max_size=<size> --s_label=<label> --s_max_size=<size> --m_label=<label> --m_max_size=<size> --l_label=<label> --l_max_size=<size> --xl_label=<label> --fail_if_xl=<false> --message_if_xl=<message> --github_api_url=<url> --files_to_ignore=<files> --ignore_file_deletions=<false>
12+
##? main.sh --github_token=<token> --xs_label=<label> --xs_max_size=<size> --s_label=<label> --s_max_size=<size> --m_label=<label> --m_max_size=<size> --l_label=<label> --l_max_size=<size> --xl_label=<label> --fail_if_xl=<false> --message_if_xl=<message> --github_api_url=<url> --files_to_ignore=<files> --ignore_line_deletions=<false>
1313
main() {
1414
eval "$(/root/bin/docpars -h "$(grep "^##?" "$PR_SIZE_LABELER_HOME/src/main.sh" | cut -c 5-)" : "$@")"
1515

@@ -32,7 +32,7 @@ main() {
3232
"$fail_if_xl" \
3333
"$message_if_xl" \
3434
"$files_to_ignore" \
35-
"$ignore_file_deletions"
35+
"$ignore_line_deletions"
3636

3737
exit $?
3838
}

0 commit comments

Comments
 (0)