From c004907b7600ddf4d9e06a8c7ff7e32566bad269 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:40:14 -0400 Subject: [PATCH 01/41] feat: Add support for listing renames. --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 26d783c5..2257e1c8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -82,7 +82,7 @@ else else echo "::set-output name=any_changed::false" fi - + OTHER_CHANGED="" if [[ -n $ALL_OTHER_CHANGED ]]; then @@ -112,7 +112,7 @@ else else echo "::set-output name=any_modified::false" fi - + OTHER_MODIFIED="" if [[ -n $ALL_OTHER_MODIFIED ]]; then @@ -142,7 +142,7 @@ else else echo "::set-output name=any_deleted::false" fi - + OTHER_DELETED="" if [[ -n $ALL_OTHER_DELETED ]]; then From 562c86f382bfa2e340444665f317f72fefa6aca0 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:41:13 -0400 Subject: [PATCH 02/41] Added a test file. --- test/test-rename.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/test-rename.txt diff --git a/test/test-rename.txt b/test/test-rename.txt new file mode 100644 index 00000000..6de7b8c6 --- /dev/null +++ b/test/test-rename.txt @@ -0,0 +1 @@ +This is a test file. From 86a97221c89e1a0151624a265dfe11ddc622e571 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:42:25 -0400 Subject: [PATCH 03/41] Renamed test-renamed.txt -> test-rename-1.txt --- test/{test-rename.txt => test-rename-1.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename.txt => test-rename-1.txt} (100%) diff --git a/test/test-rename.txt b/test/test-rename-1.txt similarity index 100% rename from test/test-rename.txt rename to test/test-rename-1.txt From 5f40fac43ce1ecb5a712a5406edaf5549e37403e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:33:40 -0400 Subject: [PATCH 04/41] Added support for returning old and new names of renamed files --- README.md | 8 ++++---- action.yml | 12 ++++++++++-- entrypoint.sh | 8 +++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 85fc018c..1d49fb90 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ Support this project with a :star: | Input | type | required | default | description | |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | -| separator | `string` | `true` | `' '` | Output string separator | +| separator | `string` | `false` | `' '` | Output string separator | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | @@ -138,9 +138,9 @@ Support this project with a :star: | sha | `string` | `true` | `${{ github.sha }}` | Specify a different
commit SHA
used for
comparing changes | | base\_sha | `string` | `false` | | Specify a different
base commit SHA
used for
comparing changes | | path | `string` | `false` | | Relative path under
`GITHUB_WORKSPACE`
to the repository | -| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | -| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | -| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | +| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | +| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | +| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | ## Example diff --git a/action.yml b/action.yml index d59b9339..e1d85d9c 100644 --- a/action.yml +++ b/action.yml @@ -5,12 +5,16 @@ author: tj-actions inputs: token: description: 'Github token' - required: true + required: false default: ${{ github.token }} separator: description: 'Split character for array output' - required: true + required: false default: " " + old_new_files_separator: + description: 'Split character for old and new filename pairs' + required: false + default: "," files_from_source_file: description: 'Source file(s) to populate the files input' required: false @@ -74,6 +78,9 @@ outputs: renamed_files: description: List of renamed files. value: ${{ steps.changed-files.outputs.renamed_files }} + old_new_files: + description: List of old and new names of renamed files. + value: ${{ steps.changed-files.outputs.old_new_files }} type_changed_files: description: List of files that had type changes. value: ${{ steps.changed-files.outputs.type_changed_files }} @@ -182,6 +189,7 @@ runs: INPUT_TARGET_BRANCH: ${{ steps.changed-files-diff-sha.outputs.target_branch }} INPUT_CURRENT_BRANCH: ${{ steps.changed-files-diff-sha.outputs.current_branch }} INPUT_QUOTEPATH: ${{ inputs.quotepath }} + INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} branding: icon: file-text diff --git a/entrypoint.sh b/entrypoint.sh index 2257e1c8..a142712f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,6 +16,7 @@ function get_diff() { base="$1" sha="$2" filter="$3" + type="${4:-name-only}" while IFS='' read -r sub; do sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" @@ -28,7 +29,7 @@ function get_diff() { ) fi done < <(git submodule | awk '{print $2}') - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base" "$sha" + git diff --diff-filter="$filter" --"$type" --ignore-submodules=all "$base" "$sha" } echo "::group::changed-files" @@ -60,6 +61,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -72,6 +74,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -174,6 +177,7 @@ else ALL_CHANGED_AND_MODIFIED=$(echo "${ALL_CHANGED_AND_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(echo "${ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(echo "${OLD_NEW}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') fi git remote remove temp_changed_files @@ -183,6 +187,7 @@ echo "Copied files: $COPIED" echo "Deleted files: $DELETED" echo "Modified files: $MODIFIED" echo "Renamed files: $RENAMED" +echo "Old new files: $OLD_NEW" echo "Type Changed files: $TYPE_CHANGED" echo "Unmerged files: $UNMERGED" echo "Unknown files: $UNKNOWN" @@ -195,6 +200,7 @@ echo "::set-output name=copied_files::$COPIED" echo "::set-output name=deleted_files::$DELETED" echo "::set-output name=modified_files::$MODIFIED" echo "::set-output name=renamed_files::$RENAMED" +echo "::set-output name=old_new_files::$OLD_NEW" echo "::set-output name=type_changed_files::$TYPE_CHANGED" echo "::set-output name=unmerged_files::$UNMERGED" echo "::set-output name=unknown_files::$UNKNOWN" From 070aa8aaf95b144eae63a7120e1adec29e18b05e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:40:44 -0400 Subject: [PATCH 05/41] Added test-rename.txt --- test/test-rename.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/test-rename.txt diff --git a/test/test-rename.txt b/test/test-rename.txt new file mode 100644 index 00000000..6de7b8c6 --- /dev/null +++ b/test/test-rename.txt @@ -0,0 +1 @@ +This is a test file. From 815b8a6dbcca130f50969e1e4c27636f6d86ccfc Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:41:17 -0400 Subject: [PATCH 06/41] Renamed test/test-rename.txt -> test/test-rename-2.txt --- test/{test-rename.txt => test-rename-2.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename.txt => test-rename-2.txt} (100%) diff --git a/test/test-rename.txt b/test/test-rename-2.txt similarity index 100% rename from test/test-rename.txt rename to test/test-rename-2.txt From 020ae6440a88da139e8737695e27e06029274dd4 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:43:09 -0400 Subject: [PATCH 07/41] Updated test.yml --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e675d0c..cad6ba30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - "**" pull_request: branches: - main @@ -18,7 +19,7 @@ jobs: uses: actions/checkout@v3 - name: shellcheck uses: reviewdog/action-shellcheck@v1.15 - + test-pull-requests-from-forks: name: Test changed-files diff on pull_requests from forks runs-on: ${{ matrix.platform }} @@ -140,7 +141,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent base sha id: changed-files-specific uses: ./ @@ -180,7 +181,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent sha id: changed-files-specific uses: ./ From fdd4ec0d740b856c2f8ff4a6c52fd508133d350a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:44:21 -0400 Subject: [PATCH 08/41] Renamed test/test-rename-1.txt -> test/test rename-1.txt --- test/{test-rename-1.txt => test rename-1.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename-1.txt => test rename-1.txt} (100%) diff --git a/test/test-rename-1.txt b/test/test rename-1.txt similarity index 100% rename from test/test-rename-1.txt rename to test/test rename-1.txt From 724e1a1fea53807e1a8968258636071e0c746701 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:44:54 -0400 Subject: [PATCH 09/41] Renamed test/test-rename-2.txt -> test/test rename-2.txt --- test/{test-rename-2.txt => test rename-2.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename-2.txt => test rename-2.txt} (100%) diff --git a/test/test-rename-2.txt b/test/test rename-2.txt similarity index 100% rename from test/test-rename-2.txt rename to test/test rename-2.txt From a8e851942c4f06a504e8862e8c4cf58469131194 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:45:46 -0400 Subject: [PATCH 10/41] Renamed test files. --- test/{test rename-1.txt => test rename 1.txt} | 0 test/{test rename-2.txt => test rename 2.txt} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/{test rename-1.txt => test rename 1.txt} (100%) rename test/{test rename-2.txt => test rename 2.txt} (100%) diff --git a/test/test rename-1.txt b/test/test rename 1.txt similarity index 100% rename from test/test rename-1.txt rename to test/test rename 1.txt diff --git a/test/test rename-2.txt b/test/test rename 2.txt similarity index 100% rename from test/test rename-2.txt rename to test/test rename 2.txt From 12bb70106645fe01d58a0d582d5e293a0438a668 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:54:45 -0400 Subject: [PATCH 11/41] Updated description. --- README.md | 48 +++++++++++++++++++++++++----------------------- action.yml | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1d49fb90..686a1bc6 100644 --- a/README.md +++ b/README.md @@ -100,35 +100,37 @@ Support this project with a :star: | U | Unmerged | | X | Unknown | -| Output | type | example | description | -|:----------------------------------:|:--------:|:--------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| -| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | -| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | -| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | -| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | -| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | -| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | -| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | -| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | -| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | -| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | -| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | -| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | -| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | -| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | -| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | -| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | -| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | -| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | -| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | -| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | +| Output | type | example | description | +|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | +| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | +| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | +| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | +| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | +| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | +| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | +| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | +| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | +| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | +| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | +| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | +| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | +| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | +| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | +| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | +| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | +| old\_new\_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | +| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | +| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | +| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | ## Inputs | Input | type | required | default | description | |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | -| separator | `string` | `false` | `' '` | Output string separator | +| separator | `string` | `false` | `' '` | Split character for output strings | +| old\_new\_files\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | diff --git a/action.yml b/action.yml index e1d85d9c..2e2bf2a5 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: required: false default: ${{ github.token }} separator: - description: 'Split character for array output' + description: 'Split character for output strings' required: false default: " " old_new_files_separator: From d1c0ee4e67338c2c3e50a08b6156ab8c155be21c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:24:13 -0400 Subject: [PATCH 12/41] Updated docs and fixed bug with old new files list --- README.md | 3 ++- action.yml | 7 ++++++- entrypoint.sh | 5 ++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 686a1bc6..e5919072 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,8 @@ Support this project with a :star: |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | | separator | `string` | `false` | `' '` | Split character for output strings | -| old\_new\_files\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | +| old\_new\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | +| old\_new\_files\_separator | `string` | `false` | `' '` | Split character for multiple old and new filename pairs | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | diff --git a/action.yml b/action.yml index 2e2bf2a5..911927b3 100644 --- a/action.yml +++ b/action.yml @@ -11,10 +11,14 @@ inputs: description: 'Split character for output strings' required: false default: " " - old_new_files_separator: + old_new_separator: description: 'Split character for old and new filename pairs' required: false default: "," + old_new_files_separator: + description: 'Split character for multiple old and new filename pairs' + required: false + default: " " files_from_source_file: description: 'Source file(s) to populate the files input' required: false @@ -189,6 +193,7 @@ runs: INPUT_TARGET_BRANCH: ${{ steps.changed-files-diff-sha.outputs.target_branch }} INPUT_CURRENT_BRANCH: ${{ steps.changed-files-diff-sha.outputs.current_branch }} INPUT_QUOTEPATH: ${{ inputs.quotepath }} + INPUT_OLD_NEW_SEPARATOR: ${{ inputs.old_new_separator }} INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} branding: diff --git a/entrypoint.sh b/entrypoint.sh index a142712f..1fd7c402 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -61,7 +61,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -74,7 +74,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -177,7 +177,6 @@ else ALL_CHANGED_AND_MODIFIED=$(echo "${ALL_CHANGED_AND_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(echo "${ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(echo "${OLD_NEW}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') fi git remote remove temp_changed_files From 4d042152e51d80466d4c04e38624641da330bca3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:24:52 -0400 Subject: [PATCH 13/41] Renamed test/test rename 1.txt -> test/test rename-1.txt --- test/{test rename 1.txt => test rename-1.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test rename 1.txt => test rename-1.txt} (100%) diff --git a/test/test rename 1.txt b/test/test rename-1.txt similarity index 100% rename from test/test rename 1.txt rename to test/test rename-1.txt From fe238e608de5130e29fee093a0afb039d72de21d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:25:17 -0400 Subject: [PATCH 14/41] Renamed test/test rename 2.txt -> test/test rename-2.txt --- test/{test rename 2.txt => test rename-2.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test rename 2.txt => test rename-2.txt} (100%) diff --git a/test/test rename 2.txt b/test/test rename-2.txt similarity index 100% rename from test/test rename 2.txt rename to test/test rename-2.txt From b711f8d3a401c5b4142d58e116679a54fc835a03 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:25:52 -0400 Subject: [PATCH 15/41] Renamed files. --- test/{test rename-1.txt => test rename 1.txt} | 0 test/{test rename-2.txt => test rename 2.txt} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/{test rename-1.txt => test rename 1.txt} (100%) rename test/{test rename-2.txt => test rename 2.txt} (100%) diff --git a/test/test rename-1.txt b/test/test rename 1.txt similarity index 100% rename from test/test rename-1.txt rename to test/test rename 1.txt diff --git a/test/test rename-2.txt b/test/test rename 2.txt similarity index 100% rename from test/test rename-2.txt rename to test/test rename 2.txt From a968e7411691e11ac6cdcbacedbda6b5e8f0b8e6 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 16:00:31 -0400 Subject: [PATCH 16/41] Reformatted table --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 85fc018c..c2c6123a 100644 --- a/README.md +++ b/README.md @@ -138,9 +138,9 @@ Support this project with a :star: | sha | `string` | `true` | `${{ github.sha }}` | Specify a different
commit SHA
used for
comparing changes | | base\_sha | `string` | `false` | | Specify a different
base commit SHA
used for
comparing changes | | path | `string` | `false` | | Relative path under
`GITHUB_WORKSPACE`
to the repository | -| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | -| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | -| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | +| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | +| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | +| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | ## Example From e42d2fcf7782c82fb36aa9a3baf2138a8b858d1a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:05:44 -0400 Subject: [PATCH 17/41] Added get_renames function --- .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++++ entrypoint.sh | 25 +++++++++++++++++++++---- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cad6ba30..1ac2d75b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -294,6 +294,42 @@ jobs: echo '${{ toJSON(steps.changed-files-specific-newline-source-file.outputs) }}' shell: bash + - name: Run changed-files for old new filenames test rename 1 + id: changed-files-old-new-1 + uses: ./ + with: + base_sha: d1c0ee4 + sha: 4d04215 + - name: Show output + run: | + echo '${{ toJSON(steps.changed-files-old-new-1.outputs) }}' + shell: + bash + - name: Check old_new_files output + if: "!contains(steps.changed-files-old-new-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" + run: | + echo "Invalid output: Expected not to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" + exit 1 + shell: + bash + - name: Run changed-files for old new filenames test rename 2 + id: changed-files-old-new-2 + uses: ./ + with: + base_sha: 4d04215 + sha: fe238e6 + - name: Show output + run: | + echo '${{ toJSON(steps.changed-files-old-new-2.outputs) }}' + shell: + bash + - name: Check old_new_files output + if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt test/test rename-2.txt')" + run: | + echo "Invalid output: Expected not to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" + exit 1 + shell: + bash - name: Run changed-files with specific files id: changed-files-specific uses: ./ diff --git a/entrypoint.sh b/entrypoint.sh index 1fd7c402..bd172c27 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,7 +16,6 @@ function get_diff() { base="$1" sha="$2" filter="$3" - type="${4:-name-only}" while IFS='' read -r sub; do sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" @@ -29,7 +28,25 @@ function get_diff() { ) fi done < <(git submodule | awk '{print $2}') - git diff --diff-filter="$filter" --"$type" --ignore-submodules=all "$base" "$sha" + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base" "$sha" +} + +function get_renames() { + base="$1" + sha="$2" + while IFS='' read -r sub; do + sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" + sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + if [ -n "$sub_commit_cur" ]; then + ( + cd "$sub" && ( + # the strange magic number is a hardcoded "empty tree" commit sha + get_renames "${sub_commit_pre:-4b825dc642cb6eb9a060e54bf8d69288fbee4904}" "${sub_commit_cur}" | awk -v r="$sub" '{ print "" r "/" $0}' + ) + ) + fi + done < <(git submodule | awk '{print $2}') + git log --name-status --ignore-submodules=all "$base" "$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' } echo "::group::changed-files" @@ -61,7 +78,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -74,7 +91,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') From 044773f27a01168b3da6560145085f2e752f4366 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:15:28 -0400 Subject: [PATCH 18/41] Updated test --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ac2d75b..ebb0f074 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -308,7 +308,7 @@ jobs: - name: Check old_new_files output if: "!contains(steps.changed-files-old-new-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" run: | - echo "Invalid output: Expected not to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" exit 1 shell: bash @@ -324,9 +324,9 @@ jobs: shell: bash - name: Check old_new_files output - if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt test/test rename-2.txt')" + if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" run: | - echo "Invalid output: Expected not to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" exit 1 shell: bash From b60efcf625f7d808d6d95840a8f4fe3486fc8396 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:54:38 -0400 Subject: [PATCH 19/41] Renamed output. --- .github/workflows/test.yml | 20 ++++++++++---------- README.md | 2 +- action.yml | 6 +++--- entrypoint.sh | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebb0f074..f965221d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -295,38 +295,38 @@ jobs: shell: bash - name: Run changed-files for old new filenames test rename 1 - id: changed-files-old-new-1 + id: changed-files-all-old-new-renamed-files-1 uses: ./ with: base_sha: d1c0ee4 sha: 4d04215 - name: Show output run: | - echo '${{ toJSON(steps.changed-files-old-new-1.outputs) }}' + echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-1.outputs) }}' shell: bash - - name: Check old_new_files output - if: "!contains(steps.changed-files-old-new-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" + - name: Check all_old_new_renamed_files output + if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files }})" exit 1 shell: bash - name: Run changed-files for old new filenames test rename 2 - id: changed-files-old-new-2 + id: changed-files-all-old-new-renamed-files-2 uses: ./ with: base_sha: 4d04215 sha: fe238e6 - name: Show output run: | - echo '${{ toJSON(steps.changed-files-old-new-2.outputs) }}' + echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-2.outputs) }}' shell: bash - - name: Check old_new_files output - if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" + - name: Check all_old_new_renamed_files output + if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files }})" exit 1 shell: bash diff --git a/README.md b/README.md index e5919072..1802ec44 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Support this project with a :star: | deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | | modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | | renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | -| old\_new\_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | +| all_old_new_renamed_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | | type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | | unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | | unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | diff --git a/action.yml b/action.yml index 911927b3..fd10f53a 100644 --- a/action.yml +++ b/action.yml @@ -82,9 +82,9 @@ outputs: renamed_files: description: List of renamed files. value: ${{ steps.changed-files.outputs.renamed_files }} - old_new_files: - description: List of old and new names of renamed files. - value: ${{ steps.changed-files.outputs.old_new_files }} + all_old_new_renamed_files: + description: List of all old and new names of renamed files. + value: ${{ steps.changed-files.outputs.all_old_new_renamed_files }} type_changed_files: description: List of files that had type changes. value: ${{ steps.changed-files.outputs.type_changed_files }} diff --git a/entrypoint.sh b/entrypoint.sh index bd172c27..b3ef8751 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -78,7 +78,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -91,7 +91,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -203,25 +203,25 @@ echo "Copied files: $COPIED" echo "Deleted files: $DELETED" echo "Modified files: $MODIFIED" echo "Renamed files: $RENAMED" -echo "Old new files: $OLD_NEW" echo "Type Changed files: $TYPE_CHANGED" echo "Unmerged files: $UNMERGED" echo "Unknown files: $UNKNOWN" echo "All changed and modified files: $ALL_CHANGED_AND_MODIFIED" echo "All changed files: $ALL_CHANGED" echo "All modified files: $ALL_MODIFIED" +echo "All old & new renamed files: $ALL_OLD_NEW_RENAMED_FILES" echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" echo "::set-output name=deleted_files::$DELETED" echo "::set-output name=modified_files::$MODIFIED" echo "::set-output name=renamed_files::$RENAMED" -echo "::set-output name=old_new_files::$OLD_NEW" echo "::set-output name=type_changed_files::$TYPE_CHANGED" echo "::set-output name=unmerged_files::$UNMERGED" echo "::set-output name=unknown_files::$UNKNOWN" echo "::set-output name=all_changed_and_modified_files::$ALL_CHANGED_AND_MODIFIED" echo "::set-output name=all_changed_files::$ALL_CHANGED" echo "::set-output name=all_modified_files::$ALL_MODIFIED" +echo "::set-output name=all_old_new_renamed_files::$ALL_OLD_NEW_RENAMED_FILES" echo "::endgroup::" From c69f784c4f2251b496fbd606323503c522fa681b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:56:47 -0400 Subject: [PATCH 20/41] Fixed test. --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f965221d..60267d27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -306,9 +306,9 @@ jobs: shell: bash - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" + if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files, 'test/test rename 1.txt,test/test rename-1.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files }})" exit 1 shell: bash @@ -324,9 +324,9 @@ jobs: shell: bash - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" + if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files, 'test/test rename 2.txt,test/test rename-2.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files }})" exit 1 shell: bash From ed9e4befd610390e37608235c4f46a7134ddbda2 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 18:27:02 -0400 Subject: [PATCH 21/41] Updated entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index b3ef8751..69301e3d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -46,7 +46,7 @@ function get_renames() { ) fi done < <(git submodule | awk '{print $2}') - git log --name-status --ignore-submodules=all "$base" "$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' + git log --name-status --ignore-submodules=all "$base".."$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' } echo "::group::changed-files" From b4def97a99728c871cc3cc7a4ce10722a4629d18 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 18:08:54 -0400 Subject: [PATCH 22/41] Revert "feat: Added support for returning old and new names of renamed files" (#485) --- .github/workflows/test.yml | 43 +++-------------------------- README.md | 55 ++++++++++++++++++-------------------- action.yml | 19 +++---------- entrypoint.sh | 4 --- test/test rename 1.txt | 1 - test/test rename 2.txt | 1 - 6 files changed, 32 insertions(+), 91 deletions(-) delete mode 100644 test/test rename 1.txt delete mode 100644 test/test rename 2.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60267d27..3e675d0c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - "**" pull_request: branches: - main @@ -19,7 +18,7 @@ jobs: uses: actions/checkout@v3 - name: shellcheck uses: reviewdog/action-shellcheck@v1.15 - + test-pull-requests-from-forks: name: Test changed-files diff on pull_requests from forks runs-on: ${{ matrix.platform }} @@ -141,7 +140,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent base sha id: changed-files-specific uses: ./ @@ -181,7 +180,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent sha id: changed-files-specific uses: ./ @@ -294,42 +293,6 @@ jobs: echo '${{ toJSON(steps.changed-files-specific-newline-source-file.outputs) }}' shell: bash - - name: Run changed-files for old new filenames test rename 1 - id: changed-files-all-old-new-renamed-files-1 - uses: ./ - with: - base_sha: d1c0ee4 - sha: 4d04215 - - name: Show output - run: | - echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-1.outputs) }}' - shell: - bash - - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files, 'test/test rename 1.txt,test/test rename-1.txt')" - run: | - echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files }})" - exit 1 - shell: - bash - - name: Run changed-files for old new filenames test rename 2 - id: changed-files-all-old-new-renamed-files-2 - uses: ./ - with: - base_sha: 4d04215 - sha: fe238e6 - - name: Show output - run: | - echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-2.outputs) }}' - shell: - bash - - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files, 'test/test rename 2.txt,test/test rename-2.txt')" - run: | - echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files }})" - exit 1 - shell: - bash - name: Run changed-files with specific files id: changed-files-specific uses: ./ diff --git a/README.md b/README.md index 1802ec44..85fc018c 100644 --- a/README.md +++ b/README.md @@ -100,38 +100,35 @@ Support this project with a :star: | U | Unmerged | | X | Unknown | -| Output | type | example | description | -|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| -| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | -| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | -| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | -| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | -| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | -| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | -| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | -| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | -| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | -| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | -| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | -| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | -| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | -| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | -| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | -| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | -| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | -| all_old_new_renamed_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | -| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | -| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | -| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | +| Output | type | example | description | +|:----------------------------------:|:--------:|:--------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | +| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | +| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | +| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | +| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | +| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | +| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | +| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | +| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | +| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | +| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | +| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | +| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | +| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | +| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | +| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | +| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | +| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | +| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | +| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | ## Inputs | Input | type | required | default | description | |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | -| separator | `string` | `false` | `' '` | Split character for output strings | -| old\_new\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | -| old\_new\_files\_separator | `string` | `false` | `' '` | Split character for multiple old and new filename pairs | +| separator | `string` | `true` | `' '` | Output string separator | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | @@ -141,9 +138,9 @@ Support this project with a :star: | sha | `string` | `true` | `${{ github.sha }}` | Specify a different
commit SHA
used for
comparing changes | | base\_sha | `string` | `false` | | Specify a different
base commit SHA
used for
comparing changes | | path | `string` | `false` | | Relative path under
`GITHUB_WORKSPACE`
to the repository | -| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | -| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | -| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | +| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | +| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | +| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | ## Example diff --git a/action.yml b/action.yml index fd10f53a..d59b9339 100644 --- a/action.yml +++ b/action.yml @@ -5,19 +5,11 @@ author: tj-actions inputs: token: description: 'Github token' - required: false + required: true default: ${{ github.token }} separator: - description: 'Split character for output strings' - required: false - default: " " - old_new_separator: - description: 'Split character for old and new filename pairs' - required: false - default: "," - old_new_files_separator: - description: 'Split character for multiple old and new filename pairs' - required: false + description: 'Split character for array output' + required: true default: " " files_from_source_file: description: 'Source file(s) to populate the files input' @@ -82,9 +74,6 @@ outputs: renamed_files: description: List of renamed files. value: ${{ steps.changed-files.outputs.renamed_files }} - all_old_new_renamed_files: - description: List of all old and new names of renamed files. - value: ${{ steps.changed-files.outputs.all_old_new_renamed_files }} type_changed_files: description: List of files that had type changes. value: ${{ steps.changed-files.outputs.type_changed_files }} @@ -193,8 +182,6 @@ runs: INPUT_TARGET_BRANCH: ${{ steps.changed-files-diff-sha.outputs.target_branch }} INPUT_CURRENT_BRANCH: ${{ steps.changed-files-diff-sha.outputs.current_branch }} INPUT_QUOTEPATH: ${{ inputs.quotepath }} - INPUT_OLD_NEW_SEPARATOR: ${{ inputs.old_new_separator }} - INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} branding: icon: file-text diff --git a/entrypoint.sh b/entrypoint.sh index 69301e3d..d15f1f0d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -78,7 +78,6 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -91,7 +90,6 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -209,7 +207,6 @@ echo "Unknown files: $UNKNOWN" echo "All changed and modified files: $ALL_CHANGED_AND_MODIFIED" echo "All changed files: $ALL_CHANGED" echo "All modified files: $ALL_MODIFIED" -echo "All old & new renamed files: $ALL_OLD_NEW_RENAMED_FILES" echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" @@ -222,6 +219,5 @@ echo "::set-output name=unknown_files::$UNKNOWN" echo "::set-output name=all_changed_and_modified_files::$ALL_CHANGED_AND_MODIFIED" echo "::set-output name=all_changed_files::$ALL_CHANGED" echo "::set-output name=all_modified_files::$ALL_MODIFIED" -echo "::set-output name=all_old_new_renamed_files::$ALL_OLD_NEW_RENAMED_FILES" echo "::endgroup::" diff --git a/test/test rename 1.txt b/test/test rename 1.txt deleted file mode 100644 index 6de7b8c6..00000000 --- a/test/test rename 1.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file. diff --git a/test/test rename 2.txt b/test/test rename 2.txt deleted file mode 100644 index 6de7b8c6..00000000 --- a/test/test rename 2.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file. From 3e205d23e0a6bb3706e5c29265cc4c675fc999c5 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:41:13 -0400 Subject: [PATCH 23/41] Added a test file. --- test/test-rename.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/test-rename.txt diff --git a/test/test-rename.txt b/test/test-rename.txt new file mode 100644 index 00000000..6de7b8c6 --- /dev/null +++ b/test/test-rename.txt @@ -0,0 +1 @@ +This is a test file. From 67e0fe5e75c8a8599399edd5b87b44ee73b22c86 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:42:25 -0400 Subject: [PATCH 24/41] Renamed test-renamed.txt -> test-rename-1.txt --- test/{test-rename.txt => test-rename-1.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename.txt => test-rename-1.txt} (100%) diff --git a/test/test-rename.txt b/test/test-rename-1.txt similarity index 100% rename from test/test-rename.txt rename to test/test-rename-1.txt From fd30e95c05a3a33d8bb4620924975dce0e126aff Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:33:40 -0400 Subject: [PATCH 25/41] Added support for returning old and new names of renamed files --- README.md | 8 ++++---- action.yml | 12 ++++++++++-- entrypoint.sh | 8 +++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 85fc018c..1d49fb90 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ Support this project with a :star: | Input | type | required | default | description | |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | -| separator | `string` | `true` | `' '` | Output string separator | +| separator | `string` | `false` | `' '` | Output string separator | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | @@ -138,9 +138,9 @@ Support this project with a :star: | sha | `string` | `true` | `${{ github.sha }}` | Specify a different
commit SHA
used for
comparing changes | | base\_sha | `string` | `false` | | Specify a different
base commit SHA
used for
comparing changes | | path | `string` | `false` | | Relative path under
`GITHUB_WORKSPACE`
to the repository | -| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | -| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | -| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | +| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | +| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | +| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | ## Example diff --git a/action.yml b/action.yml index d59b9339..e1d85d9c 100644 --- a/action.yml +++ b/action.yml @@ -5,12 +5,16 @@ author: tj-actions inputs: token: description: 'Github token' - required: true + required: false default: ${{ github.token }} separator: description: 'Split character for array output' - required: true + required: false default: " " + old_new_files_separator: + description: 'Split character for old and new filename pairs' + required: false + default: "," files_from_source_file: description: 'Source file(s) to populate the files input' required: false @@ -74,6 +78,9 @@ outputs: renamed_files: description: List of renamed files. value: ${{ steps.changed-files.outputs.renamed_files }} + old_new_files: + description: List of old and new names of renamed files. + value: ${{ steps.changed-files.outputs.old_new_files }} type_changed_files: description: List of files that had type changes. value: ${{ steps.changed-files.outputs.type_changed_files }} @@ -182,6 +189,7 @@ runs: INPUT_TARGET_BRANCH: ${{ steps.changed-files-diff-sha.outputs.target_branch }} INPUT_CURRENT_BRANCH: ${{ steps.changed-files-diff-sha.outputs.current_branch }} INPUT_QUOTEPATH: ${{ inputs.quotepath }} + INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} branding: icon: file-text diff --git a/entrypoint.sh b/entrypoint.sh index d15f1f0d..60d7b203 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,6 +16,7 @@ function get_diff() { base="$1" sha="$2" filter="$3" + type="${4:-name-only}" while IFS='' read -r sub; do sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" @@ -28,7 +29,7 @@ function get_diff() { ) fi done < <(git submodule | awk '{print $2}') - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base" "$sha" + git diff --diff-filter="$filter" --"$type" --ignore-submodules=all "$base" "$sha" } function get_renames() { @@ -78,6 +79,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -90,6 +92,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -192,6 +195,7 @@ else ALL_CHANGED_AND_MODIFIED=$(echo "${ALL_CHANGED_AND_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(echo "${ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(echo "${OLD_NEW}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') fi git remote remove temp_changed_files @@ -201,6 +205,7 @@ echo "Copied files: $COPIED" echo "Deleted files: $DELETED" echo "Modified files: $MODIFIED" echo "Renamed files: $RENAMED" +echo "Old new files: $OLD_NEW" echo "Type Changed files: $TYPE_CHANGED" echo "Unmerged files: $UNMERGED" echo "Unknown files: $UNKNOWN" @@ -213,6 +218,7 @@ echo "::set-output name=copied_files::$COPIED" echo "::set-output name=deleted_files::$DELETED" echo "::set-output name=modified_files::$MODIFIED" echo "::set-output name=renamed_files::$RENAMED" +echo "::set-output name=old_new_files::$OLD_NEW" echo "::set-output name=type_changed_files::$TYPE_CHANGED" echo "::set-output name=unmerged_files::$UNMERGED" echo "::set-output name=unknown_files::$UNKNOWN" From 23cf07c0bc2e93904b127146821d4edcaf6c58a2 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:40:44 -0400 Subject: [PATCH 26/41] Added test-rename.txt --- test/test-rename.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/test-rename.txt diff --git a/test/test-rename.txt b/test/test-rename.txt new file mode 100644 index 00000000..6de7b8c6 --- /dev/null +++ b/test/test-rename.txt @@ -0,0 +1 @@ +This is a test file. From 9dcecf749d5a3eb8271e23fb248a1f053058edab Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:41:17 -0400 Subject: [PATCH 27/41] Renamed test/test-rename.txt -> test/test-rename-2.txt --- test/{test-rename.txt => test-rename-2.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename.txt => test-rename-2.txt} (100%) diff --git a/test/test-rename.txt b/test/test-rename-2.txt similarity index 100% rename from test/test-rename.txt rename to test/test-rename-2.txt From 7f7bafe37a65ed2359e60cbe2573d28b4deba260 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:43:09 -0400 Subject: [PATCH 28/41] Updated test.yml --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e675d0c..cad6ba30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - "**" pull_request: branches: - main @@ -18,7 +19,7 @@ jobs: uses: actions/checkout@v3 - name: shellcheck uses: reviewdog/action-shellcheck@v1.15 - + test-pull-requests-from-forks: name: Test changed-files diff on pull_requests from forks runs-on: ${{ matrix.platform }} @@ -140,7 +141,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent base sha id: changed-files-specific uses: ./ @@ -180,7 +181,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent sha id: changed-files-specific uses: ./ From b1873d49194886b7070d0441a727d731dcb71a77 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:44:21 -0400 Subject: [PATCH 29/41] Renamed test/test-rename-1.txt -> test/test rename-1.txt --- test/{test-rename-1.txt => test rename-1.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename-1.txt => test rename-1.txt} (100%) diff --git a/test/test-rename-1.txt b/test/test rename-1.txt similarity index 100% rename from test/test-rename-1.txt rename to test/test rename-1.txt From 09ca4109ada84755cc5a84af51ab3d1c853f56b3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:44:54 -0400 Subject: [PATCH 30/41] Renamed test/test-rename-2.txt -> test/test rename-2.txt --- test/{test-rename-2.txt => test rename-2.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test-rename-2.txt => test rename-2.txt} (100%) diff --git a/test/test-rename-2.txt b/test/test rename-2.txt similarity index 100% rename from test/test-rename-2.txt rename to test/test rename-2.txt From 02c29677a69748b9eaa5070d81d54be978a80a57 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:45:46 -0400 Subject: [PATCH 31/41] Renamed test files. --- test/{test rename-1.txt => test rename 1.txt} | 0 test/{test rename-2.txt => test rename 2.txt} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/{test rename-1.txt => test rename 1.txt} (100%) rename test/{test rename-2.txt => test rename 2.txt} (100%) diff --git a/test/test rename-1.txt b/test/test rename 1.txt similarity index 100% rename from test/test rename-1.txt rename to test/test rename 1.txt diff --git a/test/test rename-2.txt b/test/test rename 2.txt similarity index 100% rename from test/test rename-2.txt rename to test/test rename 2.txt From fbb03cca8456584de1fe7445f0a4eac1f25ec8ae Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:54:45 -0400 Subject: [PATCH 32/41] Updated description. --- README.md | 48 +++++++++++++++++++++++++----------------------- action.yml | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1d49fb90..686a1bc6 100644 --- a/README.md +++ b/README.md @@ -100,35 +100,37 @@ Support this project with a :star: | U | Unmerged | | X | Unknown | -| Output | type | example | description | -|:----------------------------------:|:--------:|:--------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| -| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | -| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | -| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | -| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | -| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | -| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | -| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | -| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | -| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | -| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | -| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | -| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | -| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | -| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | -| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | -| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | -| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | -| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | -| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | -| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | +| Output | type | example | description | +|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | +| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | +| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | +| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | +| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | +| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | +| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | +| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | +| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | +| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | +| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | +| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | +| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | +| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | +| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | +| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | +| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | +| old\_new\_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | +| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | +| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | +| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | ## Inputs | Input | type | required | default | description | |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | -| separator | `string` | `false` | `' '` | Output string separator | +| separator | `string` | `false` | `' '` | Split character for output strings | +| old\_new\_files\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | diff --git a/action.yml b/action.yml index e1d85d9c..2e2bf2a5 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: required: false default: ${{ github.token }} separator: - description: 'Split character for array output' + description: 'Split character for output strings' required: false default: " " old_new_files_separator: From 423833260b47c360c6b392b096292926b3867a26 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:24:13 -0400 Subject: [PATCH 33/41] Updated docs and fixed bug with old new files list --- README.md | 3 ++- action.yml | 7 ++++++- entrypoint.sh | 5 ++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 686a1bc6..e5919072 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,8 @@ Support this project with a :star: |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | | separator | `string` | `false` | `' '` | Split character for output strings | -| old\_new\_files\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | +| old\_new\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | +| old\_new\_files\_separator | `string` | `false` | `' '` | Split character for multiple old and new filename pairs | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | diff --git a/action.yml b/action.yml index 2e2bf2a5..911927b3 100644 --- a/action.yml +++ b/action.yml @@ -11,10 +11,14 @@ inputs: description: 'Split character for output strings' required: false default: " " - old_new_files_separator: + old_new_separator: description: 'Split character for old and new filename pairs' required: false default: "," + old_new_files_separator: + description: 'Split character for multiple old and new filename pairs' + required: false + default: " " files_from_source_file: description: 'Source file(s) to populate the files input' required: false @@ -189,6 +193,7 @@ runs: INPUT_TARGET_BRANCH: ${{ steps.changed-files-diff-sha.outputs.target_branch }} INPUT_CURRENT_BRANCH: ${{ steps.changed-files-diff-sha.outputs.current_branch }} INPUT_QUOTEPATH: ${{ inputs.quotepath }} + INPUT_OLD_NEW_SEPARATOR: ${{ inputs.old_new_separator }} INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} branding: diff --git a/entrypoint.sh b/entrypoint.sh index 60d7b203..03acd450 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -79,7 +79,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -92,7 +92,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_SEPARATOR" '{print $2d$3}' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -195,7 +195,6 @@ else ALL_CHANGED_AND_MODIFIED=$(echo "${ALL_CHANGED_AND_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(echo "${ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(echo "${OLD_NEW}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') fi git remote remove temp_changed_files From 5b5e575c4c57b24771e20150ece26e384e37568a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:24:52 -0400 Subject: [PATCH 34/41] Renamed test/test rename 1.txt -> test/test rename-1.txt --- test/{test rename 1.txt => test rename-1.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test rename 1.txt => test rename-1.txt} (100%) diff --git a/test/test rename 1.txt b/test/test rename-1.txt similarity index 100% rename from test/test rename 1.txt rename to test/test rename-1.txt From 8138d89db11cd4e8251652943e64d01a1f011b77 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:25:17 -0400 Subject: [PATCH 35/41] Renamed test/test rename 2.txt -> test/test rename-2.txt --- test/{test rename 2.txt => test rename-2.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test rename 2.txt => test rename-2.txt} (100%) diff --git a/test/test rename 2.txt b/test/test rename-2.txt similarity index 100% rename from test/test rename 2.txt rename to test/test rename-2.txt From 74d37f129ff98617c166bc55a6586b83bf2906f0 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:25:52 -0400 Subject: [PATCH 36/41] Renamed files. --- test/{test rename-1.txt => test rename 1.txt} | 0 test/{test rename-2.txt => test rename 2.txt} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/{test rename-1.txt => test rename 1.txt} (100%) rename test/{test rename-2.txt => test rename 2.txt} (100%) diff --git a/test/test rename-1.txt b/test/test rename 1.txt similarity index 100% rename from test/test rename-1.txt rename to test/test rename 1.txt diff --git a/test/test rename-2.txt b/test/test rename 2.txt similarity index 100% rename from test/test rename-2.txt rename to test/test rename 2.txt From c815c5df178e1c5fadc97bb225d32a670efb97b2 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:05:44 -0400 Subject: [PATCH 37/41] Added get_renames function --- .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++++ entrypoint.sh | 25 +++++++++++++++++++++---- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cad6ba30..1ac2d75b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -294,6 +294,42 @@ jobs: echo '${{ toJSON(steps.changed-files-specific-newline-source-file.outputs) }}' shell: bash + - name: Run changed-files for old new filenames test rename 1 + id: changed-files-old-new-1 + uses: ./ + with: + base_sha: d1c0ee4 + sha: 4d04215 + - name: Show output + run: | + echo '${{ toJSON(steps.changed-files-old-new-1.outputs) }}' + shell: + bash + - name: Check old_new_files output + if: "!contains(steps.changed-files-old-new-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" + run: | + echo "Invalid output: Expected not to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" + exit 1 + shell: + bash + - name: Run changed-files for old new filenames test rename 2 + id: changed-files-old-new-2 + uses: ./ + with: + base_sha: 4d04215 + sha: fe238e6 + - name: Show output + run: | + echo '${{ toJSON(steps.changed-files-old-new-2.outputs) }}' + shell: + bash + - name: Check old_new_files output + if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt test/test rename-2.txt')" + run: | + echo "Invalid output: Expected not to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" + exit 1 + shell: + bash - name: Run changed-files with specific files id: changed-files-specific uses: ./ diff --git a/entrypoint.sh b/entrypoint.sh index 03acd450..06876ded 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,7 +16,6 @@ function get_diff() { base="$1" sha="$2" filter="$3" - type="${4:-name-only}" while IFS='' read -r sub; do sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" @@ -29,7 +28,25 @@ function get_diff() { ) fi done < <(git submodule | awk '{print $2}') - git diff --diff-filter="$filter" --"$type" --ignore-submodules=all "$base" "$sha" + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base" "$sha" +} + +function get_renames() { + base="$1" + sha="$2" + while IFS='' read -r sub; do + sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" + sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + if [ -n "$sub_commit_cur" ]; then + ( + cd "$sub" && ( + # the strange magic number is a hardcoded "empty tree" commit sha + get_renames "${sub_commit_pre:-4b825dc642cb6eb9a060e54bf8d69288fbee4904}" "${sub_commit_cur}" | awk -v r="$sub" '{ print "" r "/" $0}' + ) + ) + fi + done < <(git submodule | awk '{print $2}') + git log --name-status --ignore-submodules=all "$base" "$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' } function get_renames() { @@ -79,7 +96,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -92,7 +109,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') From 4b7f83fb7a374664a03b240313aeb11d81940c4e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:15:28 -0400 Subject: [PATCH 38/41] Updated test --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ac2d75b..ebb0f074 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -308,7 +308,7 @@ jobs: - name: Check old_new_files output if: "!contains(steps.changed-files-old-new-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" run: | - echo "Invalid output: Expected not to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" exit 1 shell: bash @@ -324,9 +324,9 @@ jobs: shell: bash - name: Check old_new_files output - if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt test/test rename-2.txt')" + if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" run: | - echo "Invalid output: Expected not to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" exit 1 shell: bash From 1abdcf81f3ce226042a394b3d1157a6b80494e3f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:54:38 -0400 Subject: [PATCH 39/41] Renamed output. --- .github/workflows/test.yml | 20 ++++++++++---------- README.md | 2 +- action.yml | 6 +++--- entrypoint.sh | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebb0f074..f965221d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -295,38 +295,38 @@ jobs: shell: bash - name: Run changed-files for old new filenames test rename 1 - id: changed-files-old-new-1 + id: changed-files-all-old-new-renamed-files-1 uses: ./ with: base_sha: d1c0ee4 sha: 4d04215 - name: Show output run: | - echo '${{ toJSON(steps.changed-files-old-new-1.outputs) }}' + echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-1.outputs) }}' shell: bash - - name: Check old_new_files output - if: "!contains(steps.changed-files-old-new-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" + - name: Check all_old_new_renamed_files output + if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-old-new-1.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files }})" exit 1 shell: bash - name: Run changed-files for old new filenames test rename 2 - id: changed-files-old-new-2 + id: changed-files-all-old-new-renamed-files-2 uses: ./ with: base_sha: 4d04215 sha: fe238e6 - name: Show output run: | - echo '${{ toJSON(steps.changed-files-old-new-2.outputs) }}' + echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-2.outputs) }}' shell: bash - - name: Check old_new_files output - if: "!contains(steps.changed-files-old-new-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" + - name: Check all_old_new_renamed_files output + if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-old-new-2.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files }})" exit 1 shell: bash diff --git a/README.md b/README.md index e5919072..1802ec44 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Support this project with a :star: | deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | | modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | | renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | -| old\_new\_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | +| all_old_new_renamed_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | | type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | | unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | | unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | diff --git a/action.yml b/action.yml index 911927b3..fd10f53a 100644 --- a/action.yml +++ b/action.yml @@ -82,9 +82,9 @@ outputs: renamed_files: description: List of renamed files. value: ${{ steps.changed-files.outputs.renamed_files }} - old_new_files: - description: List of old and new names of renamed files. - value: ${{ steps.changed-files.outputs.old_new_files }} + all_old_new_renamed_files: + description: List of all old and new names of renamed files. + value: ${{ steps.changed-files.outputs.all_old_new_renamed_files }} type_changed_files: description: List of files that had type changes. value: ${{ steps.changed-files.outputs.type_changed_files }} diff --git a/entrypoint.sh b/entrypoint.sh index 06876ded..90d1f285 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -96,7 +96,7 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -109,7 +109,7 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - OLD_NEW=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -221,25 +221,25 @@ echo "Copied files: $COPIED" echo "Deleted files: $DELETED" echo "Modified files: $MODIFIED" echo "Renamed files: $RENAMED" -echo "Old new files: $OLD_NEW" echo "Type Changed files: $TYPE_CHANGED" echo "Unmerged files: $UNMERGED" echo "Unknown files: $UNKNOWN" echo "All changed and modified files: $ALL_CHANGED_AND_MODIFIED" echo "All changed files: $ALL_CHANGED" echo "All modified files: $ALL_MODIFIED" +echo "All old & new renamed files: $ALL_OLD_NEW_RENAMED_FILES" echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" echo "::set-output name=deleted_files::$DELETED" echo "::set-output name=modified_files::$MODIFIED" echo "::set-output name=renamed_files::$RENAMED" -echo "::set-output name=old_new_files::$OLD_NEW" echo "::set-output name=type_changed_files::$TYPE_CHANGED" echo "::set-output name=unmerged_files::$UNMERGED" echo "::set-output name=unknown_files::$UNKNOWN" echo "::set-output name=all_changed_and_modified_files::$ALL_CHANGED_AND_MODIFIED" echo "::set-output name=all_changed_files::$ALL_CHANGED" echo "::set-output name=all_modified_files::$ALL_MODIFIED" +echo "::set-output name=all_old_new_renamed_files::$ALL_OLD_NEW_RENAMED_FILES" echo "::endgroup::" From 939ae1be50bbdf8e0807de7ff54369c3d810496f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:56:47 -0400 Subject: [PATCH 40/41] Fixed test. --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f965221d..60267d27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -306,9 +306,9 @@ jobs: shell: bash - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files, 'test/test rename 1.txt,test/test rename-1.txt')" + if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files, 'test/test rename 1.txt,test/test rename-1.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files }})" exit 1 shell: bash @@ -324,9 +324,9 @@ jobs: shell: bash - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files, 'test/test rename 2.txt,test/test rename-2.txt')" + if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files, 'test/test rename 2.txt,test/test rename-2.txt')" run: | - echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.old_new_files }})" + echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files }})" exit 1 shell: bash From 0a05f634b66807d56192d297bad5343b5e45f3c2 Mon Sep 17 00:00:00 2001 From: jackton1 Date: Sat, 14 May 2022 22:06:30 +0000 Subject: [PATCH 41/41] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1802ec44..b5caa93d 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Support this project with a :star: | deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | | modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | | renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | -| all_old_new_renamed_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | +| all\_old\_new\_renamed\_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | | type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | | unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | | unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) |