Skip to content

Commit

Permalink
Merge pull request #287 from tj-actions/fix/handle-new-line-used-as-s…
Browse files Browse the repository at this point in the history
…eparator

fix: handle new line used as separator
  • Loading branch information
repo-ranger[bot] authored Apr 19, 2023
2 parents ce64891 + 9f9d3cf commit 183324b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test files has no changes an no warning with autocrlf
uses: ./
id: changed_files_not_expected_autocrlf
with:
autocrlf: true
files: |
test/*.txt
test/*.sql
test/**/*.txt
test/**/*.sql
- name: Display changed files
if: steps.changed_files_not_expected_autocrlf.outputs.files_changed == 'true'
run: |
echo "Changed files (Not expected): ${{ steps.changed_files_not_expected_autocrlf.outputs.changed_files }}"
exit 1
- name: Test files has no changes
uses: ./
id: changed_files_not_expected
Expand All @@ -61,10 +46,13 @@ jobs:
- name: Make changes
run: |
printf '%s\n' "323442" "424" >> test/new.txt
printf '%s\n' "323442" "424" >> test/new1.txt
printf '%s\n' "323442" "424" >> test/new2.txt
- name: Test test/new.txt file has changes
uses: ./
id: changed_files_expected
with:
separator: '\n'
files: |
test/*.txt
test/*.sql
Expand Down Expand Up @@ -103,6 +91,8 @@ jobs:
with:
files: |
!test/new.txt
!test/new1.txt
!test/new2.txt
!unstaged.txt
- name: Verify Changes to unstaged.txt are ignored
if: steps.changed_unstaged_files_not_expected.outputs.files_changed != 'false'
Expand All @@ -115,6 +105,8 @@ jobs:
with:
files: |
!test/new.txt
!test/new1.txt
!test/new2.txt
unstaged.txt
- name: Verify Changes to unstaged.txt are ignored
if: steps.changed_unstaged2_files_expected.outputs.files_changed != 'true'
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ Support this project with a :star:

* Free software: [MIT license](LICENSE)


## Known Limitation

> **Warning**:
>
> * Using characters like `\n`, `%`, `.` and `\r` as separators would be [URL encoded](https://www.w3schools.com/tags/ref_urlencode.asp)

## Report Bugs

Report bugs at https://github.com/tj-actions/verify-changed-files/issues.
Expand Down
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ set -e

echo "::group::verify-changed-files"

INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}"
INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}"
INPUT_SEPARATOR="${INPUT_SEPARATOR//\\n/%0A}"
INPUT_SEPARATOR="${INPUT_SEPARATOR//\\r/%0D}"

echo "Separator: $INPUT_SEPARATOR"

if [[ -n "$INPUT_FILES_PATTERN_FILE" ]]; then
TRACKED_FILES=$(git diff --diff-filter=ACMUXTRD --name-only | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')

Expand Down

0 comments on commit 183324b

Please sign in to comment.