From 86faf92e73b8e35eeaaca7dc32395bbe30d8b51c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 22:12:18 -0600 Subject: [PATCH 01/20] fix: handle new line used as separator --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d4178ea..e371dd3 100644 --- a/README.md +++ b/README.md @@ -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. From 5bd0f97acbf68191afbef0ec4f8e08ec440d6d62 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 22:13:37 -0600 Subject: [PATCH 02/20] Update entrypoint.sh --- entrypoint.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 8334954..5f7108d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,11 @@ set -e +INPUT_SEPARATOR="${INPUT_SEPARATOR//'%'/'%25'}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//'.'/'%2E'}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\n'/'%0A'}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/'%0D'}" + echo "::group::verify-changed-files" if [[ -n "$INPUT_FILES_PATTERN_FILE" ]]; then From 18de328c38954ddf862b747f7bb2b5031f9776a0 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 22:19:03 -0600 Subject: [PATCH 03/20] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9037986..7de5464 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,6 @@ jobs: uses: ./ id: changed_files_not_expected_autocrlf with: - autocrlf: true files: | test/*.txt test/*.sql @@ -65,6 +64,7 @@ jobs: uses: ./ id: changed_files_expected with: + separator: '\n' files: | test/*.txt test/*.sql From ffa65df64b110e43c93a6f17f9664293721ab935 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 22:23:11 -0600 Subject: [PATCH 04/20] Update test.yml --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7de5464..33ddadd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,6 +60,8 @@ 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 From f583de068ba95b925ac6f38ed5ac131cc6b831fc Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 22:28:01 -0600 Subject: [PATCH 05/20] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5f7108d..d6d3501 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -exuo pipefail INPUT_SEPARATOR="${INPUT_SEPARATOR//'%'/'%25'}" INPUT_SEPARATOR="${INPUT_SEPARATOR//'.'/'%2E'}" From 75968c8784f3f9ec8480f7b1733c1e1269fe7a20 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 22:29:17 -0600 Subject: [PATCH 06/20] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index d6d3501..cb49942 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -exuo pipefail +set -ex INPUT_SEPARATOR="${INPUT_SEPARATOR//'%'/'%25'}" INPUT_SEPARATOR="${INPUT_SEPARATOR//'.'/'%2E'}" From 51e4371fb39bbbd2702ff4c8a5d2fefca7fd097d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 22:33:24 -0600 Subject: [PATCH 07/20] Update entrypoint.sh --- entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index cb49942..e5280b8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,10 +2,10 @@ set -ex -INPUT_SEPARATOR="${INPUT_SEPARATOR//'%'/'%25'}" -INPUT_SEPARATOR="${INPUT_SEPARATOR//'.'/'%2E'}" -INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\n'/'%0A'}" -INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/'%0D'}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/\%25}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//\./\%2E}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\n'/\%0A}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/\%0D}" echo "::group::verify-changed-files" From a234cef7dcbe12b6951caed020f1f8e1c4eeb781 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:01:33 -0600 Subject: [PATCH 08/20] Update entrypoint.sh --- entrypoint.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index e5280b8..98df2b5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,10 +2,16 @@ set -ex -INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/\%25}" -INPUT_SEPARATOR="${INPUT_SEPARATOR//\./\%2E}" -INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\n'/\%0A}" -INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/\%0D}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" + +NEWLINE_SEPARATOR=$'\n' +URLENCODED_NEWLINE_SEPARATOR="%0A" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" + +CARRIAGE_RETURN=$'\r' +URLENCODED_CARRIAGE_RETURN="%0D" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" echo "::group::verify-changed-files" From ca6cbe4b424faf23de507e7a949b3939565f4242 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:02:56 -0600 Subject: [PATCH 09/20] Update entrypoint.sh --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 98df2b5..9c20528 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,11 +5,11 @@ set -ex INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" -NEWLINE_SEPARATOR=$'\n' +NEWLINE_SEPARATOR="\n" URLENCODED_NEWLINE_SEPARATOR="%0A" INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" -CARRIAGE_RETURN=$'\r' +CARRIAGE_RETURN="\r" URLENCODED_CARRIAGE_RETURN="%0D" INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" From a6214120d30d16222597f6a4f9ced8fb9bbef5fe Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:16:26 -0600 Subject: [PATCH 10/20] Update test.yml --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 33ddadd..07de8c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -105,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_unstaged_files_not_expected.outputs.files_changed != 'false' @@ -117,6 +119,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' From ab271093300ac6094613bf2244302ff319076112 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:18:51 -0600 Subject: [PATCH 11/20] Update test.yml --- .github/workflows/test.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 07de8c7..be5d762 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,20 +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: - 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 From 04f4c5f125280604fae6247b2d211bdf761cef79 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:22:33 -0600 Subject: [PATCH 12/20] Update entrypoint.sh --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9c20528..f0de5a8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,11 +5,11 @@ set -ex INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" -NEWLINE_SEPARATOR="\n" +NEWLINE_SEPARATOR="\\n" URLENCODED_NEWLINE_SEPARATOR="%0A" INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" -CARRIAGE_RETURN="\r" +CARRIAGE_RETURN="\\r" URLENCODED_CARRIAGE_RETURN="%0D" INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" From 3e537435ba871b07d2f710aa251764f43f47d940 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:32:05 -0600 Subject: [PATCH 13/20] Update entrypoint.sh --- entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f0de5a8..8d19771 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,12 +5,12 @@ set -ex INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" -NEWLINE_SEPARATOR="\\n" -URLENCODED_NEWLINE_SEPARATOR="%0A" +NEWLINE_SEPARATOR=$'\n' +URLENCODED_NEWLINE_SEPARATOR='%0A' INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" -CARRIAGE_RETURN="\\r" -URLENCODED_CARRIAGE_RETURN="%0D" +CARRIAGE_RETURN=$'\r' +URLENCODED_CARRIAGE_RETURN='%0D' INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" echo "::group::verify-changed-files" From aea97c99b503f5ff80c356906d9aa38b893bf504 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:33:17 -0600 Subject: [PATCH 14/20] Update entrypoint.sh --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8d19771..caaae13 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,11 +5,11 @@ set -ex INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" -NEWLINE_SEPARATOR=$'\n' +NEWLINE_SEPARATOR="\n" URLENCODED_NEWLINE_SEPARATOR='%0A' INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" -CARRIAGE_RETURN=$'\r' +CARRIAGE_RETURN="\r" URLENCODED_CARRIAGE_RETURN='%0D' INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" From 2c230b947b442bee0131b2784f89e6010e66cc90 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:37:34 -0600 Subject: [PATCH 15/20] Update entrypoint.sh --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index caaae13..87d5f34 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,11 +5,11 @@ set -ex INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" -NEWLINE_SEPARATOR="\n" +NEWLINE_SEPARATOR='\n' URLENCODED_NEWLINE_SEPARATOR='%0A' INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" -CARRIAGE_RETURN="\r" +CARRIAGE_RETURN='\r' URLENCODED_CARRIAGE_RETURN='%0D' INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" From d6be76fddfd526372454a4d379726f372beb8611 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 18 Apr 2023 23:47:54 -0600 Subject: [PATCH 16/20] Update entrypoint.sh --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 87d5f34..8d19771 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,11 +5,11 @@ set -ex INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" -NEWLINE_SEPARATOR='\n' +NEWLINE_SEPARATOR=$'\n' URLENCODED_NEWLINE_SEPARATOR='%0A' INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" -CARRIAGE_RETURN='\r' +CARRIAGE_RETURN=$'\r' URLENCODED_CARRIAGE_RETURN='%0D' INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" From 05912690e7b4905de8d61f898da7be0f78f1cd5b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Wed, 19 Apr 2023 00:18:50 -0600 Subject: [PATCH 17/20] Update entrypoint.sh --- entrypoint.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8d19771..dfc9782 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,18 +2,20 @@ set -ex +echo "::group::verify-changed-files" + INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" -NEWLINE_SEPARATOR=$'\n' +NEWLINE_SEPARATOR='\n' URLENCODED_NEWLINE_SEPARATOR='%0A' -INPUT_SEPARATOR="${INPUT_SEPARATOR//$NEWLINE_SEPARATOR/$URLENCODED_NEWLINE_SEPARATOR}" +INPUT_SEPARATOR=$(echo "$INPUT_SEPARATOR" | sed "s/${NEWLINE_SEPARATOR}/${URLENCODED_NEWLINE_SEPARATOR}/g") -CARRIAGE_RETURN=$'\r' +CARRIAGE_RETURN='\r' URLENCODED_CARRIAGE_RETURN='%0D' -INPUT_SEPARATOR="${INPUT_SEPARATOR//$CARRIAGE_RETURN/$URLENCODED_CARRIAGE_RETURN}" +INPUT_SEPARATOR=$(echo "$INPUT_SEPARATOR" | sed "s/${CARRIAGE_RETURN}/${URLENCODED_CARRIAGE_RETURN}/g") -echo "::group::verify-changed-files" +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}') From 5c103de0a1b94528bbfc9ef5a16459e8d2123c91 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Wed, 19 Apr 2023 00:30:55 -0600 Subject: [PATCH 18/20] Update entrypoint.sh --- entrypoint.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index dfc9782..26ac537 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,14 +6,8 @@ echo "::group::verify-changed-files" INPUT_SEPARATOR="${INPUT_SEPARATOR//\%/%25}" INPUT_SEPARATOR="${INPUT_SEPARATOR//\./%2E}" - -NEWLINE_SEPARATOR='\n' -URLENCODED_NEWLINE_SEPARATOR='%0A' -INPUT_SEPARATOR=$(echo "$INPUT_SEPARATOR" | sed "s/${NEWLINE_SEPARATOR}/${URLENCODED_NEWLINE_SEPARATOR}/g") - -CARRIAGE_RETURN='\r' -URLENCODED_CARRIAGE_RETURN='%0D' -INPUT_SEPARATOR=$(echo "$INPUT_SEPARATOR" | sed "s/${CARRIAGE_RETURN}/${URLENCODED_CARRIAGE_RETURN}/g") +INPUT_SEPARATOR="${INPUT_SEPARATOR//\n/%0A}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//\r/%0D}" echo "Separator: $INPUT_SEPARATOR" From ce01bef432947d5855982544f3507b9ffd920767 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Wed, 19 Apr 2023 00:33:22 -0600 Subject: [PATCH 19/20] Update entrypoint.sh --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 26ac537..87f0ec0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,8 +6,8 @@ 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}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//\\n/%0A}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//\\r/%0D}" echo "Separator: $INPUT_SEPARATOR" From 9f9d3cfdff0259e1f339ca5e1c46cd5948e6fa58 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Wed, 19 Apr 2023 00:37:13 -0600 Subject: [PATCH 20/20] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 87f0ec0..3d13712 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -ex +set -e echo "::group::verify-changed-files"