Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle new line used as separator #287

Merged
merged 20 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)


Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 1; Actual: 2

Expected: 1; Actual: 2
## Known Limitation

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

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 1; Actual: 3

Expected: 1; Actual: 3

## 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