From f5a8de7d36c5909d300d7fcc8d6340d2a56ab9d9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 8 Mar 2022 06:59:26 -0500 Subject: [PATCH] fix: bug using newline separator (#418) --- .github/workflows/test.yml | 22 ++++++++++++++++++++++ README.md | 1 + entrypoint.sh | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3046a35..ac813a24 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -237,6 +237,16 @@ jobs: echo '${{ toJSON(steps.changed-files-forward-slash.outputs) }}' shell: bash + - name: Run changed-files with newline separator + id: changed-files-newline + uses: ./ + with: + separator: "\n" + - name: Show output + run: | + echo '${{ toJSON(steps.changed-files-newline.outputs) }}' + shell: + bash - name: Run changed-files with pipe separator id: changed-files-pipe uses: ./ @@ -257,6 +267,18 @@ jobs: echo '${{ toJSON(steps.changed-files-comma.outputs) }}' shell: bash + - name: Run changed-files with specific files from a source file using a newline separator + id: changed-files-specific-newline-source-file + uses: ./ + with: + files_from_source_file: | + test/changed-files-list.txt + separator: "\n" + - name: Show output + run: | + echo '${{ toJSON(steps.changed-files-specific-newline-source-file.outputs) }}' + shell: + bash - name: Run changed-files with specific files id: changed-files-specific uses: ./ diff --git a/README.md b/README.md index c2f7c59d..4446f3d1 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,7 @@ Support this project with a :star: > NOTE: :warning: > +> * Using characters like `\n`, `%` and `\r` as separators would be [URL encoded](https://www.w3schools.com/tags/ref_urlencode.asp) > * Spaces in file names can introduce bugs when using bash loops. See: [#216](https://github.com/tj-actions/changed-files/issues/216) > * However, this action will handle spaces in file names, with a recommendation of using a separator to prevent hidden issues. > ![Screen Shot 2021-10-23 at 9 37 34 AM](https://user-images.githubusercontent.com/17484350/138558767-b13c90bf-a1ae-4e86-9520-70a6a4624f41.png) diff --git a/entrypoint.sh b/entrypoint.sh index f48d01c6..146f6a44 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,10 @@ set -eu +INPUT_SEPARATOR="${INPUT_SEPARATOR//'%'/'%25'}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\n'/'%0A'}" +INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/'%0D'}" + function get_diff() { base="$1" sha="$2"