Skip to content

Commit

Permalink
Merge pull request #1 from CodelyTV/main
Browse files Browse the repository at this point in the history
feat: add regex match for files to ignore (CodelyTV#50)
  • Loading branch information
Vico1993 committed Mar 1, 2023
2 parents 54ef367 + d269449 commit ed7f750
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ jobs:
- `fail_if_xl`: Set to `'true'` will report GitHub Workflow failure if the PR size is xl allowing to forbid PR merge
- `message_if_xl`: Let the user(s) know that the PR exceeds the recommended size and what the consequences are
- `github_api_url`: Override this parameter in order to use with your own GitHub Enterprise Server. Example: `'https://github.example.com/api/v3'`
- `files_to_ignore`: Whitespace separated list of files to ignore when calculating the PR size. Example: `'package-lock.json Pipfile.lock'`

- `files_to_ignore`: Whitespace or newline separated list of files to ignore when calculating the PR size, regex match is supported.
### files_to_ignore Example:
```yml
files_to_ignore: 'package-lock.json *.lock'
# OR
files_to_ignore: |
"package-lock.json"
"*.lock"
"docs/*"
```
## 🤔 Basic concepts or assumptions

- PR size labeler consider as a change any kind of line addition, deletion, or modification
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bash --version
source "$PR_SIZE_LABELER_HOME/src/main.sh"

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

Expand Down
5 changes: 4 additions & 1 deletion src/github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ github::calculate_total_modifications() {
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
if [ -z "$file_to_ignore" ]; then
continue
fi
if [[ "$(jq::base64 '.filename')" == $file_to_ignore ]]; then
ignore_file=1
fi
done
Expand Down

0 comments on commit ed7f750

Please sign in to comment.