Skip to content

Commit ed7f750

Browse files
authored
Merge pull request #1 from CodelyTV/main
feat: add regex match for files to ignore (CodelyTV#50)
2 parents 54ef367 + d269449 commit ed7f750

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ jobs:
6262
- `fail_if_xl`: Set to `'true'` will report GitHub Workflow failure if the PR size is xl allowing to forbid PR merge
6363
- `message_if_xl`: Let the user(s) know that the PR exceeds the recommended size and what the consequences are
6464
- `github_api_url`: Override this parameter in order to use with your own GitHub Enterprise Server. Example: `'https://github.example.com/api/v3'`
65-
- `files_to_ignore`: Whitespace separated list of files to ignore when calculating the PR size. Example: `'package-lock.json Pipfile.lock'`
66-
65+
- `files_to_ignore`: Whitespace or newline separated list of files to ignore when calculating the PR size, regex match is supported.
66+
### files_to_ignore Example:
67+
```yml
68+
files_to_ignore: 'package-lock.json *.lock'
69+
# OR
70+
files_to_ignore: |
71+
"package-lock.json"
72+
"*.lock"
73+
"docs/*"
74+
```
6775
## 🤔 Basic concepts or assumptions
6876

6977
- PR size labeler consider as a change any kind of line addition, deletion, or modification

entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bash --version
1414
source "$PR_SIZE_LABELER_HOME/src/main.sh"
1515

1616
for a in "${@}"; do
17-
arg=$(echo "$a" | tr -d '\n'| sed "s/'//g"| sed "s/’//g")
17+
arg=$(echo "$a" | tr '\n' ' ' | xargs echo | sed "s/'//g"| sed "s/’//g")
1818
sanitizedArgs+=("$arg")
1919
done
2020

src/github.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ github::calculate_total_modifications() {
2121
for file in $(echo "$body" | jq -r '.[] | @base64'); do
2222
local ignore_file=0
2323
for file_to_ignore in $files_to_ignore; do
24-
if [ "$file_to_ignore" = "$(basename $(jq::base64 '.filename'))" ]; then
24+
if [ -z "$file_to_ignore" ]; then
25+
continue
26+
fi
27+
if [[ "$(jq::base64 '.filename')" == $file_to_ignore ]]; then
2528
ignore_file=1
2629
fi
2730
done

0 commit comments

Comments
 (0)