3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2025-01-07 09:50:42 +00:00

Detect deleted files via any_changed output (#149)

This commit is contained in:
Tonye Jack 2021-07-30 12:14:01 -04:00 committed by GitHub
parent 3a01bb540d
commit 2c0d12b627
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -79,7 +79,7 @@ jobs:
| Output | type | example | description | | Output | type | example | description |
|:--------------------:|:------------:|:----------------------------------:|:----------------------------------------:| |:--------------------:|:------------:|:----------------------------------:|:----------------------------------------:|
| any_changed | `string` | `true` OR `false` | Returns `true` when any <br /> of the filenames provided using <br /> the `files` input has changed (ACMR) | | any_changed | `string` | `true` OR `false` | Returns `true` when any <br /> of the filenames provided using <br /> the `files` input has changed (ACMDR) |
| only_changed | `string` | `true` OR `false` | Returns `true` when only <br /> files provided using <br /> the `files` input have changed. | | only_changed | `string` | `true` OR `false` | Returns `true` when only <br /> files provided using <br /> the `files` input have changed. |
| other_changed_files | `string` | `'new.txt path/to/file.png ...'` | Select all modified files <br/> not listed in the files input <br /> i.e. *a combination of all added, <br /> copied and modified files (ACM).* | | other_changed_files | `string` | `'new.txt path/to/file.png ...'` | Select all modified files <br/> not listed in the files input <br /> i.e. *a combination of all added, <br /> copied and modified files (ACM).* |
| all_modified_files | `string` | `'new.txt path/to/file.png ...'` | Select all modified files <br /> i.e. *a combination of all added, <br />copied, modified and renamed files (ACMR).* | | all_modified_files | `string` | `'new.txt path/to/file.png ...'` | Select all modified files <br /> i.e. *a combination of all added, <br />copied, modified and renamed files (ACMR).* |

View file

@ -64,7 +64,7 @@ if [[ -z "$UNIQUE_FILES" ]]; then
UNMERGED=$(git diff --diff-filter=U --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") UNMERGED=$(git diff --diff-filter=U --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
UNKNOWN=$(git diff --diff-filter=X --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") UNKNOWN=$(git diff --diff-filter=X --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
ALL_CHANGED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") ALL_CHANGED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
ALL_MODIFIED_FILES=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") ALL_MODIFIED_FILES=$(git diff --diff-filter="ACMDR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
else else
ADDED_ARRAY=() ADDED_ARRAY=()
COPIED_ARRAY=() COPIED_ARRAY=()
@ -100,7 +100,7 @@ else
# shellcheck disable=SC2207 # shellcheck disable=SC2207
ALL_CHANGED_ARRAY+=($(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true)) ALL_CHANGED_ARRAY+=($(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
ALL_MODIFIED_FILES_ARRAY+=($(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true)) ALL_MODIFIED_FILES_ARRAY+=($(git diff --diff-filter="ACMDR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
done done
# shellcheck disable=SC2001 # shellcheck disable=SC2001
@ -139,7 +139,7 @@ echo "All modified files: $ALL_MODIFIED_FILES"
if [[ -n "$UNIQUE_FILES" ]]; then if [[ -n "$UNIQUE_FILES" ]]; then
# shellcheck disable=SC2001 # shellcheck disable=SC2001
ALL_INPUT_FILES=$(echo "$UNIQUE_FILES" | tr "\n" " " | xargs) ALL_INPUT_FILES=$(echo "$UNIQUE_FILES" | tr "\n" " " | xargs)
ALL_OTHER_CHANGED_FILES=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA") ALL_OTHER_CHANGED_FILES=$(git diff --diff-filter="ACMDR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA")
OTHER_CHANGED_FILES=$(echo "${ALL_OTHER_CHANGED_FILES[@]}" "${ALL_MODIFIED_FILES[@]}" | tr ' ' '\n' | sort | uniq -u | tr "\n" " " | xargs) OTHER_CHANGED_FILES=$(echo "${ALL_OTHER_CHANGED_FILES[@]}" "${ALL_MODIFIED_FILES[@]}" | tr ' ' '\n' | sort | uniq -u | tr "\n" " " | xargs)