Compare commits

..

9 Commits
v8.6 ... v8.8

Author SHA1 Message Date
Tonye Jack
8c6f276ea5 Added support for detecting non specific file changes. (#137) 2021-07-17 15:13:26 -04:00
Tonye Jack
cb4914b39a Upgraded to v8.7 (#136)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-07-17 11:59:23 -04:00
Tonye Jack
d825b1f709 Update test.yml 2021-07-17 11:54:59 -04:00
Tonye Jack
ca4eaaf129 Update README.md 2021-07-17 11:53:36 -04:00
Tonye Jack
4530127b24 Update README.md 2021-07-17 11:52:34 -04:00
Tonye Jack
a22f734463 Update README.md 2021-07-17 11:49:12 -04:00
Tonye Jack
43ddf0c457 Added support for a custom base sha. (#135) 2021-07-17 11:46:59 -04:00
Tonye Jack
2096ed00f7 Upgraded to v8.6 (#134)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-07-17 11:03:41 -04:00
Tonye Jack
20681a5b4f Update README.md 2021-07-17 11:01:24 -04:00
5 changed files with 154 additions and 47 deletions

View File

@@ -129,7 +129,7 @@ jobs:
id: changed-files-specific-source-file id: changed-files-specific-source-file
uses: ./ uses: ./
with: with:
files-from-source-file: | files_from_source_file: |
test/changed-files-list.txt test/changed-files-list.txt
test/changed-files-list.txt test/changed-files-list.txt
files: | files: |
@@ -152,7 +152,7 @@ jobs:
id: changed-files-specific-comma-source-file id: changed-files-specific-comma-source-file
uses: ./ uses: ./
with: with:
files-from-source-file: | files_from_source_file: |
test/changed-files-list.txt test/changed-files-list.txt
separator: "," separator: ","
- name: Verify any_changed files comma separator - name: Verify any_changed files comma separator
@@ -179,3 +179,42 @@ jobs:
echo "${{ toJSON(steps.changed-files-custom-sha.outputs) }}" echo "${{ toJSON(steps.changed-files-custom-sha.outputs) }}"
shell: shell:
bash bash
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v4.5
- uses: nrwl/last-successful-commit-action@v1
id: last_successful_commit
with:
branch: ${{ steps.branch-name.outputs.base_ref_branch }}
workflow_id: 'test.yml'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run changed-files with a custom base sha
id: changed-files-custom-base-sha
uses: ./
with:
base_sha: ${{ steps.last_successful_commit.outputs.commit_hash }}
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}"
shell:
bash
- name: Run changed-files with specific files (only-changed)
id: changed-files-specific-only-changed
uses: ./
with:
files: |
.github/workflows/test.yml
- name: Verify only_changed files
if: steps.changed-files-specific-only-changed.outputs.other_changed_files != ''
run: |
if [[ "${{ steps.changed-files-specific-only-changed.outputs.only_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-only-changed.outputs.only_changed }})"
exit 1
fi
shell:
bash
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific-only-changed.outputs) }}"
shell:
bash

View File

@@ -1,5 +1,33 @@
# Changelog # Changelog
## [v8.7](https://github.com/tj-actions/changed-files/tree/v8.7) (2021-07-17)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v8.6...v8.7)
**Implemented enhancements:**
- \[Feature\] Get Changed files since last successful Action run [\#131](https://github.com/tj-actions/changed-files/issues/131)
**Merged pull requests:**
- Added support for a custom base sha. [\#135](https://github.com/tj-actions/changed-files/pull/135) ([jackton1](https://github.com/jackton1))
- Upgraded to v8.6 [\#134](https://github.com/tj-actions/changed-files/pull/134) ([jackton1](https://github.com/jackton1))
## [v8.6](https://github.com/tj-actions/changed-files/tree/v8.6) (2021-07-17)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v8.5...v8.6)
**Implemented enhancements:**
- \[Feature\] Get specific changed files reading a file [\#130](https://github.com/tj-actions/changed-files/issues/130)
- \[Feature\] Rename `files` -\> `paths` [\#125](https://github.com/tj-actions/changed-files/issues/125)
**Merged pull requests:**
- Updated README.md [\#133](https://github.com/tj-actions/changed-files/pull/133) ([jackton1](https://github.com/jackton1))
- Added support for retrieving the files input using a source file. [\#132](https://github.com/tj-actions/changed-files/pull/132) ([jackton1](https://github.com/jackton1))
- Upgraded to v8.5 [\#129](https://github.com/tj-actions/changed-files/pull/129) ([jackton1](https://github.com/jackton1))
## [v8.5](https://github.com/tj-actions/changed-files/tree/v8.5) (2021-07-14) ## [v8.5](https://github.com/tj-actions/changed-files/tree/v8.5) (2021-07-14)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v8.4...v8.5) [Full Changelog](https://github.com/tj-actions/changed-files/compare/v8.4...v8.5)

View File

@@ -55,7 +55,7 @@ jobs:
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
uses: tj-actions/changed-files@v8.5 uses: tj-actions/changed-files@v8.7
- name: List all modified files - name: List all modified files
run: | run: |
@@ -79,7 +79,9 @@ jobs:
| Output | type | example | description | | Output | type | example | description |
|:--------------------:|:------------:|:----------------------------------:|:----------------------------------------:| |:--------------------:|:------------:|:----------------------------------:|:----------------------------------------:|
| any_changed | `string` | `true` OR `false` | Returns `true` when any of the filenames provided using the `files` input has changed | | any_changed | `string` | `true` OR `false` | Returns `true` when any of the filenames provided using the `files` input has changed |
| only_changed | `string` | `true` OR `false` | Returns `true` when only files provided using 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).* |
| all_modified_files | `string` | `'new.txt path/to/file.png ...'` | Select all modified files <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 and modified files (ACM).* |
| all_changed_files | `string` | `'new.txt path/to/file.png ...'` | Select all paths (\*) <br /> i.e. *a combination of all options below.* | | all_changed_files | `string` | `'new.txt path/to/file.png ...'` | Select all paths (\*) <br /> i.e. *a combination of all options below.* |
| added_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | | added_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) |
@@ -97,9 +99,10 @@ jobs:
|:-------------:|:-----------:|:-------------:|:-----------------------------:|:-------------:| |:-------------:|:-----------:|:-------------:|:-----------------------------:|:-------------:|
| 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) <br /> or a repo scoped <br /> [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | | 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) <br /> or a repo scoped <br /> [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` | `true` | `' '` | Output string separator |
| files | `string` OR `string[]` | `false` | | Check for changes <br> using only these list of file(s) <br> (Defaults to the entire repo) | | files | `string` OR `string[]` | `false` | | Check for changes <br> using only these <br> list of file(s) <br> (Defaults to the <br> entire repo) |
| sha | `string` | `true` | `${{ github.sha }}` | Specify a different <br> commit SHA used for comparing changes | | base_sha | `string` | `false` | | Specify a different <br> base commit SHA <br> used for <br> comparing changes |
| files-from-source-file | `string` | `false` | | Source file used populate <br> the files input. | | sha | `string` | `true` | `${{ github.sha }}` | Specify a different <br> commit SHA <br> used for <br> comparing changes |
| files_from_source_file | `string` | `false` | | Source file <br> used to populate <br> the files input |
## Example ## Example
@@ -110,11 +113,11 @@ jobs:
- name: Get changed files using defaults - name: Get changed files using defaults
id: changed-files id: changed-files
uses: tj-actions/changed-files@v8.5 uses: tj-actions/changed-files@v8.7
- name: Get changed files using a comma separator - name: Get changed files using a comma separator
id: changed-files-comma id: changed-files-comma
uses: tj-actions/changed-files@v8.5 uses: tj-actions/changed-files@v8.7
with: with:
separator: "," separator: ","
@@ -136,7 +139,7 @@ jobs:
- name: Get specific changed files - name: Get specific changed files
id: changed-files-specific id: changed-files-specific
uses: tj-actions/changed-files@v8.5 uses: tj-actions/changed-files@v8.7
with: with:
files: | files: |
my-file.txt my-file.txt
@@ -154,25 +157,31 @@ jobs:
- name: Use a source file or list of file(s) to populate to files input. - name: Use a source file or list of file(s) to populate to files input.
id: changed-files-specific-source-file id: changed-files-specific-source-file
uses: ./ uses: tj-actions/changed-files@v8.7
with: with:
files-from-source-file: | files_from_source_file: |
test/changed-files-list.txt test/changed-files-list.txt
- name: Use a source file or list of file(s) to populate to files input and optionally specify more files. - name: Use a source file or list of file(s) to populate to files input and optionally specify more files.
id: changed-files-specific-source-file-and-specify-files id: changed-files-specific-source-file-and-specify-files
uses: ./ uses: tj-actions/changed-files@v8.7
with: with:
files-from-source-file: | files_from_source_file: |
test/changed-files-list.txt test/changed-files-list.txt
files: | files: |
.github/workflows/rebase.yml .github/workflows/rebase.yml
- name: Use a different commit SHA - name: Use a different commit SHA
id: changed-files-comma id: changed-files-custom-sha
uses: tj-actions/changed-files@v8.5 uses: tj-actions/changed-files@v8.7
with: with:
sha: ${{ github.event.pull_request.head.sha }} sha: ${{ github.event.pull_request.head.sha }}
- name: Use a different base SHA
id: changed-files-custom-base-sha
uses: tj-actions/changed-files@v8.7
with:
base_sha: "2096ed0"
``` ```
@@ -187,7 +196,7 @@ jobs:
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
uses: tj-actions/changed-files@v8.5 uses: tj-actions/changed-files@v8.7
- name: Pre-commit - name: Pre-commit
uses: pre-commit/action@v2.0.0 uses: pre-commit/action@v2.0.0

View File

@@ -10,7 +10,7 @@ inputs:
description: 'Split character for array output' description: 'Split character for array output'
required: true required: true
default: " " default: " "
files-from-source-file: files_from_source_file:
description: 'Source file to populate the files input' description: 'Source file to populate the files input'
required: false required: false
default: "" default: ""
@@ -19,9 +19,12 @@ inputs:
required: false required: false
default: "" default: ""
sha: sha:
description: 'Specify a different commit SHA used for comparing changes' description: 'Specify a current commit SHA used for comparing changes'
required: true required: true
default: ${{ github.sha }} default: ${{ github.sha }}
base_sha:
description: 'Specify a base commit SHA on used for comparing changes'
required: false
outputs: outputs:
added_files: added_files:
@@ -57,6 +60,12 @@ outputs:
any_changed: any_changed:
description: Return true only when any files provided using the files input have changed. description: Return true only when any files provided using the files input have changed.
value: ${{ steps.changed-files.outputs.any_changed }} value: ${{ steps.changed-files.outputs.any_changed }}
only_changed:
description: Return true only when only files provided using the files input have changed.
value: ${{ steps.changed-files.outputs.only_changed }}
other_changed_files:
description: Return list of changed files not listed in the files input.
value: ${{ steps.changed-files.outputs.other_changed_files }}
runs: runs:
using: 'composite' using: 'composite'
@@ -76,7 +85,7 @@ runs:
shell: bash shell: bash
env: env:
INPUT_FILES: ${{ inputs.files }} INPUT_FILES: ${{ inputs.files }}
INPUT_FILES_FROM_SOURCE_FILE: ${{ inputs.files-from-source-file }} INPUT_FILES_FROM_SOURCE_FILE: ${{ inputs.files_from_source_file }}
- run: | - run: |
bash $GITHUB_ACTION_PATH/entrypoint.sh bash $GITHUB_ACTION_PATH/entrypoint.sh
id: changed-files id: changed-files
@@ -87,6 +96,7 @@ runs:
# INPUT_<VARIABLE_NAME> is not available in Composite run steps # INPUT_<VARIABLE_NAME> is not available in Composite run steps
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_SHA: ${{ inputs.sha }} INPUT_SHA: ${{ inputs.sha }}
INPUT_BASE_SHA: ${{ inputs.base_sha }}
INPUT_TOKEN: ${{ inputs.token }} INPUT_TOKEN: ${{ inputs.token }}
INPUT_FILES: ${{ join(format('{0} {1}', inputs.files, steps.source-input-files.outputs.files), ' ') }} INPUT_FILES: ${{ join(format('{0} {1}', inputs.files, steps.source-input-files.outputs.files), ' ') }}
INPUT_SEPARATOR: ${{ inputs.separator }} INPUT_SEPARATOR: ${{ inputs.separator }}

View File

@@ -9,9 +9,9 @@ git remote set-url origin "https://${INPUT_TOKEN}@github.com/${GITHUB_REPOSITORY
echo "Getting HEAD info..." echo "Getting HEAD info..."
if [[ -z $INPUT_SHA ]]; then if [[ -z $INPUT_SHA ]]; then
CURR_SHA=$(git rev-parse HEAD 2>&1) && exit_status=$? || exit_status=$? CURRENT_SHA=$(git rev-parse HEAD 2>&1) && exit_status=$? || exit_status=$?
else else
CURR_SHA=$INPUT_SHA CURRENT_SHA=$INPUT_SHA
fi fi
if [[ $exit_status -ne 0 ]]; then if [[ $exit_status -ne 0 ]]; then
@@ -20,7 +20,11 @@ if [[ $exit_status -ne 0 ]]; then
fi fi
if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $GITHUB_BASE_REF ]]; then
PREV_SHA=$(git rev-parse HEAD^1 2>&1) && exit_status=$? || exit_status=$? if [[ -z $INPUT_BASE_SHA ]]; then
PREVIOUS_SHA=$(git rev-parse HEAD^1 2>&1) && exit_status=$? || exit_status=$?
else
PREVIOUS_SHA=$INPUT_BASE_SHA
fi
TARGET_BRANCH=${GITHUB_REF/refs\/heads\//} TARGET_BRANCH=${GITHUB_REF/refs\/heads\//}
CURRENT_BRANCH=$TARGET_BRANCH CURRENT_BRANCH=$TARGET_BRANCH
@@ -30,10 +34,14 @@ if [[ -z $GITHUB_BASE_REF ]]; then
exit 1 exit 1
fi fi
else else
TARGET_BRANCH=${GITHUB_BASE_REF} TARGET_BRANCH=$GITHUB_BASE_REF
CURRENT_BRANCH=$GITHUB_HEAD_REF CURRENT_BRANCH=$GITHUB_HEAD_REF
git fetch --depth=1 origin "${TARGET_BRANCH}":"${TARGET_BRANCH}" git fetch origin "${TARGET_BRANCH}":"${TARGET_BRANCH}"
PREV_SHA=$(git rev-parse "${TARGET_BRANCH}" 2>&1) && exit_status=$? || exit_status=$? if [[ -z $INPUT_BASE_SHA ]]; then
PREVIOUS_SHA=$(git rev-parse "${TARGET_BRANCH}" 2>&1) && exit_status=$? || exit_status=$?
else
PREVIOUS_SHA=$INPUT_BASE_SHA
fi
if [[ $exit_status -ne 0 ]]; then if [[ $exit_status -ne 0 ]]; then
echo "::warning::Unable to determine the base ref sha for ${TARGET_BRANCH}" echo "::warning::Unable to determine the base ref sha for ${TARGET_BRANCH}"
@@ -41,22 +49,22 @@ else
fi fi
fi fi
echo "Retrieving changes between $PREV_SHA ($TARGET_BRANCH) → $CURR_SHA ($CURRENT_BRANCH)" echo "Retrieving changes between $PREVIOUS_SHA ($TARGET_BRANCH) → $CURRENT_SHA ($CURRENT_BRANCH)"
UNIQUE_FILES=$(echo "$INPUT_FILES" | tr ' ' '\n' | sort -u | xargs) UNIQUE_FILES=$(echo "$INPUT_FILES" | tr ' ' '\n' | sort -u | xargs)
if [[ -z "$UNIQUE_FILES" ]]; then if [[ -z "$UNIQUE_FILES" ]]; then
echo "Getting diff..." echo "Getting diff..."
ADDED=$(git diff --diff-filter=A --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") ADDED=$(git diff --diff-filter=A --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
COPIED=$(git diff --diff-filter=C --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") COPIED=$(git diff --diff-filter=C --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
DELETED=$(git diff --diff-filter=D --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") DELETED=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
MODIFIED=$(git diff --diff-filter=M --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") MODIFIED=$(git diff --diff-filter=M --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
RENAMED=$(git diff --diff-filter=R --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") RENAMED=$(git diff --diff-filter=R --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
TYPE_CHANGED=$(git diff --diff-filter=T --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") TYPE_CHANGED=$(git diff --diff-filter=T --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
UNMERGED=$(git diff --diff-filter=U --name-only "$PREV_SHA" "$CURR_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 "$PREV_SHA" "$CURR_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 "$PREV_SHA" "$CURR_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="ACM" --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") ALL_MODIFIED_FILES=$(git diff --diff-filter="ACM" --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=()
@@ -74,25 +82,25 @@ else
echo "Checking for file changes: \"${path}\"..." echo "Checking for file changes: \"${path}\"..."
IFS=" " IFS=" "
# shellcheck disable=SC2207 # shellcheck disable=SC2207
ADDED_ARRAY+=($(git diff --diff-filter=A --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) ADDED_ARRAY+=($(git diff --diff-filter=A --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COPIED_ARRAY+=($(git diff --diff-filter=C --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) COPIED_ARRAY+=($(git diff --diff-filter=C --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
DELETED_ARRAY+=($(git diff --diff-filter=D --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) DELETED_ARRAY+=($(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
MODIFIED_ARRAY+=($(git diff --diff-filter=M --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) MODIFIED_ARRAY+=($(git diff --diff-filter=M --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
RENAMED_ARRAY+=($(git diff --diff-filter=R --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) RENAMED_ARRAY+=($(git diff --diff-filter=R --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
TYPE_CHANGED_ARRAY+=($(git diff --diff-filter=T --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) TYPE_CHANGED_ARRAY+=($(git diff --diff-filter=T --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
UNMERGED_ARRAY+=($(git diff --diff-filter=U --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) UNMERGED_ARRAY+=($(git diff --diff-filter=U --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
UNKNOWN_ARRAY+=($(git diff --diff-filter=X --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) UNKNOWN_ARRAY+=($(git diff --diff-filter=X --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
# shellcheck disable=SC2207 # shellcheck disable=SC2207
ALL_CHANGED_ARRAY+=($(git diff --diff-filter="*ACDMRTUX" --name-only "$PREV_SHA" "$CURR_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="ACM" --name-only "$PREV_SHA" "$CURR_SHA" | grep -E "(${path})" | xargs || true)) ALL_MODIFIED_FILES_ARRAY+=($(git diff --diff-filter="ACM" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs || true))
done done
# shellcheck disable=SC2001 # shellcheck disable=SC2001
@@ -131,14 +139,27 @@ 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="ACM" --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)
echo "Input files: ${ALL_INPUT_FILES[*]}" echo "Input files: ${ALL_INPUT_FILES[*]}"
echo "Matching modified files: ${ALL_MODIFIED_FILES[*]}" echo "Matching modified files: ${ALL_MODIFIED_FILES[*]}"
if [[ -n "$ALL_MODIFIED_FILES" ]]; then if [[ -n "$ALL_MODIFIED_FILES" ]]; then
echo "::set-output name=any_changed::true" echo "::set-output name=any_changed::true"
else else
echo "::set-output name=any_changed::false" echo "::set-output name=any_changed::false"
fi fi
if [[ -n "$OTHER_CHANGED_FILES" ]]; then
echo "Non Matching modified files: ${OTHER_CHANGED_FILES[*]}"
echo "::set-output name=only_changed::false"
echo "::set-output name=other_changed_files::$OTHER_CHANGED_FILES"
else
echo "::set-output name=only_changed::true"
fi
fi fi
echo "::set-output name=added_files::$ADDED" echo "::set-output name=added_files::$ADDED"