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"