From 4523c1be3d2b673b0b4cda0d5144f753aa800ae1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 14 May 2022 15:24:13 -0400 Subject: [PATCH] Updated docs and fixed bug with old new files list --- README.md | 3 ++- action.yml | 7 ++++++- entrypoint.sh | 5 ++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 686a1bc6..e5919072 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,8 @@ 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 | -| old\_new\_files\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | +| 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) | | 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 | diff --git a/action.yml b/action.yml index 2e2bf2a5..911927b3 100644 --- a/action.yml +++ b/action.yml @@ -11,10 +11,14 @@ inputs: description: 'Split character for output strings' required: false default: " " - old_new_files_separator: + old_new_separator: description: 'Split character for old and new filename pairs' required: false default: "," + old_new_files_separator: + description: 'Split character for multiple old and new filename pairs' + required: false + default: " " files_from_source_file: description: 'Source file(s) to populate the files input' required: false @@ -189,6 +193,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_SEPARATOR: ${{ inputs.old_new_separator }} INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} branding: diff --git a/entrypoint.sh b/entrypoint.sh index a142712f..1fd7c402 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -61,7 +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}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_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}') @@ -74,7 +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}') + OLD_NEW=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R "name-status" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{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}') @@ -177,7 +177,6 @@ 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