mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-17 19:17:45 +00:00
Added support for returning old and new names of renamed files
This commit is contained in:
parent
9ee57c0871
commit
c65a184a68
3 changed files with 21 additions and 7 deletions
|
@ -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) <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` | `false` | `' '` | Output string separator |
|
||||
| files | `string` OR `string[]` | `false` | | Check for changes <br> using only these <br> list of file(s) <br> (Defaults to the <br> entire repo) |
|
||||
| files\_separator | string | `false` | `'\n'` | Separator used to split the<br>`files` input |
|
||||
| files\_from\_source\_file | `string` | `false` | | Source file(s) <br> used to populate <br> the `files` input |
|
||||
|
|
12
action.yml
12
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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue