From 3baba755794f9583e433f7f64200ca7540198fc1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 18:05:59 -0400 Subject: [PATCH 01/22] feat: Added support for returning old and new names of renamed files (#483) --- .github/workflows/test.yml | 43 ++++++++++++++++++++++++++--- README.md | 55 ++++++++++++++++++++------------------ action.yml | 19 ++++++++++--- entrypoint.sh | 28 ++++++++++++++++--- test/test rename 1.txt | 1 + test/test rename 2.txt | 1 + 6 files changed, 112 insertions(+), 35 deletions(-) create mode 100644 test/test rename 1.txt create mode 100644 test/test rename 2.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e675d0c..60267d27 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: ./ @@ -293,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-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 85fc018c..1802ec44 100644 --- a/README.md +++ b/README.md @@ -100,35 +100,38 @@ 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) | +| 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) | ## 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` | `true` | `' '` | Output string separator | +| 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 | | 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 +141,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..fd10f53a 100644 --- a/action.yml +++ b/action.yml @@ -5,11 +5,19 @@ author: tj-actions inputs: token: description: 'Github token' - required: true + required: false default: ${{ github.token }} separator: - description: 'Split character for array output' - required: true + 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 default: " " files_from_source_file: description: 'Source file(s) to populate the files input' @@ -74,6 +82,9 @@ 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 }} @@ -182,6 +193,8 @@ 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 26d783c5..b3ef8751 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -31,6 +31,24 @@ function get_diff() { 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" echo "Resolving repository path..." @@ -60,6 +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}') + 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}') @@ -72,6 +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}') + 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}') @@ -82,7 +102,7 @@ else else echo "::set-output name=any_changed::false" fi - + OTHER_CHANGED="" if [[ -n $ALL_OTHER_CHANGED ]]; then @@ -112,7 +132,7 @@ else else echo "::set-output name=any_modified::false" fi - + OTHER_MODIFIED="" if [[ -n $ALL_OTHER_MODIFIED ]]; then @@ -142,7 +162,7 @@ else else echo "::set-output name=any_deleted::false" fi - + OTHER_DELETED="" if [[ -n $ALL_OTHER_DELETED ]]; then @@ -189,6 +209,7 @@ 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" @@ -201,5 +222,6 @@ 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 new file mode 100644 index 00000000..6de7b8c6 --- /dev/null +++ b/test/test rename 1.txt @@ -0,0 +1 @@ +This is a test file. diff --git a/test/test rename 2.txt b/test/test rename 2.txt new file mode 100644 index 00000000..6de7b8c6 --- /dev/null +++ b/test/test rename 2.txt @@ -0,0 +1 @@ +This is a test file. From 0093196671172756e7facde8b01c10fe420f8807 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 18:08:54 -0400 Subject: [PATCH 02/22] 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 | 28 +++---------------- test/test rename 1.txt | 1 - test/test rename 2.txt | 1 - 6 files changed, 35 insertions(+), 112 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 b3ef8751..26d783c5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -31,24 +31,6 @@ function get_diff() { 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" echo "Resolving repository path..." @@ -78,7 +60,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 +72,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}') @@ -102,7 +82,7 @@ else else echo "::set-output name=any_changed::false" fi - + OTHER_CHANGED="" if [[ -n $ALL_OTHER_CHANGED ]]; then @@ -132,7 +112,7 @@ else else echo "::set-output name=any_modified::false" fi - + OTHER_MODIFIED="" if [[ -n $ALL_OTHER_MODIFIED ]]; then @@ -162,7 +142,7 @@ else else echo "::set-output name=any_deleted::false" fi - + OTHER_DELETED="" if [[ -n $ALL_OTHER_DELETED ]]; then @@ -209,7 +189,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 +201,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 f1a01ff091fb1c66e4d984fa0b6d73667552ee84 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:40:14 -0400 Subject: [PATCH 03/22] 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 a47fe7c04353cefbd7e6da3e28e6abf91f375bcb Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:41:13 -0400 Subject: [PATCH 04/22] 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 9ee57c08714dc9cd44612c0ac26f3f647c4fc311 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 13:42:25 -0400 Subject: [PATCH 05/22] 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 c65a184a68f0ac8ebc63549638d007282f4106a8 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:33:40 -0400 Subject: [PATCH 06/22] 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 c91875f5c7c83154c7eb0f7179684d494530b29d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:40:44 -0400 Subject: [PATCH 07/22] 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 1b9b564b1b6a16eae417aaf38c2ea47fdcf35145 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:41:17 -0400 Subject: [PATCH 08/22] 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 8567a10991ed7d6ed8c85ce1669be4298199198d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:43:09 -0400 Subject: [PATCH 09/22] 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 ac7e9e740966216f3874cdaccebd41e7a0501f92 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:44:21 -0400 Subject: [PATCH 10/22] 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 c632bba0e4f10785962cba4d9e45ac24b25c4122 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:44:54 -0400 Subject: [PATCH 11/22] 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 7d223a463850b6d6e286dbac755410937e089966 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:45:46 -0400 Subject: [PATCH 12/22] 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 8ee5785691f17da7ce30330db867d75279250998 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 14:54:45 -0400 Subject: [PATCH 13/22] 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 4523c1be3d2b673b0b4cda0d5144f753aa800ae1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:24:13 -0400 Subject: [PATCH 14/22] 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 915804c2500922d5b59579ab0e21720b82c9a7ac Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:24:52 -0400 Subject: [PATCH 15/22] 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 33a8d4202a8087f12921928f273011608a80ebe9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:25:17 -0400 Subject: [PATCH 16/22] 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 4f723c8a08e68c97743541cd399dfdad302150d6 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:25:52 -0400 Subject: [PATCH 17/22] 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 6655125c375e25e3ddcf2a19c6ae780459d1cdc0 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:05:44 -0400 Subject: [PATCH 18/22] 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 f96d468a04cdd384393719ab0e57580c3af98c4a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:15:28 -0400 Subject: [PATCH 19/22] 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 ce04a71447362a550c0f3cf64fbf2bea03c6c20a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:54:38 -0400 Subject: [PATCH 20/22] 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 7a19e1f563c45b97f72f2de02c4e48657d043bce Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 17:56:47 -0400 Subject: [PATCH 21/22] 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 07b38ce1a17c46f1d0eb1150c8a33f703d473262 Mon Sep 17 00:00:00 2001 From: jackton1 Date: Sat, 14 May 2022 22:06:30 +0000 Subject: [PATCH 22/22] 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) |