diff --git a/.github/workflows/manual-test.yml b/.github/workflows/manual-test.yml index efae96ba..a5972bec 100644 --- a/.github/workflows/manual-test.yml +++ b/.github/workflows/manual-test.yml @@ -27,7 +27,6 @@ jobs: - name: Show output run: | echo '${{ toJSON(steps.changed-files.outputs) }}' - - name: Run changed-files with glob filtering id: changed-files-glob uses: ./ @@ -38,3 +37,15 @@ jobs: - name: Show output run: | echo '${{ toJSON(steps.changed-files-glob.outputs) }}' + + - name: Run changed-files with glob filtering and all_old_new_renamed_files + id: changed-files-glob-all-old-new-renamed-files + uses: ./ + with: + include_all_old_new_renamed_files: true + files: | + test/*.txt + + - name: Show output + run: | + echo '${{ toJSON(steps.changed-files-glob-all-old-new-renamed-files.outputs) }}' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60267d27..41192bd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -300,6 +300,7 @@ jobs: with: base_sha: d1c0ee4 sha: 4d04215 + include_all_old_new_renamed_files: true - name: Show output run: | echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-1.outputs) }}' @@ -318,6 +319,7 @@ jobs: with: base_sha: 4d04215 sha: fe238e6 + include_all_old_new_renamed_files: true - name: Show output run: | echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-2.outputs) }}' diff --git a/README.md b/README.md index 9de837ac..c5bad31d 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ 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 | +| include\_all\_old\_new\_renamed\_files | `boolean` | `false` | `false` | Include `all_old_new_renamed_files` output. Note this can generate a large debug output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | | 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) | @@ -140,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 | `boolean` | `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 | `boolean` | `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 | `boolean` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | ## Example diff --git a/action.yml b/action.yml index fd10f53a..c0a85082 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,10 @@ inputs: description: 'Split character for output strings' required: false default: " " + include_all_old_new_renamed_files: + description: 'Include all_old_new_renamed_files output. Note this can generate a large debug output See: #501.' + required: false + default: false old_new_separator: description: 'Split character for old and new filename pairs' required: false @@ -193,6 +197,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_INCLUDE_ALL_OLD_NEW_RENAMED_FILES: ${{ inputs.include_all_old_new_renamed_files }} INPUT_OLD_NEW_SEPARATOR: ${{ inputs.old_new_separator }} INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} diff --git a/entrypoint.sh b/entrypoint.sh index 4a40056d..d07e3008 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -79,7 +79,9 @@ 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}') + if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then + 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}') + fi 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 +94,9 @@ 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 -w -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then + ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -w -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') + fi 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}') @@ -208,7 +212,9 @@ 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" +if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then + echo "All old & new renamed files: $ALL_OLD_NEW_RENAMED_FILES" +fi echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" @@ -221,6 +227,8 @@ 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" +if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then + echo "::set-output name=all_old_new_renamed_files::$ALL_OLD_NEW_RENAMED_FILES" +fi echo "::endgroup::"