3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-17 03:47:20 +00:00

Added better logging.

This commit is contained in:
Tonye Jack 2021-05-01 16:26:36 -04:00
parent b2c601819d
commit 18496eb7e4

View file

@ -57,6 +57,7 @@ runs:
export INPUT_FILES="${{ inputs.files }}" export INPUT_FILES="${{ inputs.files }}"
export INPUT_SEPARATOR="${{ inputs.separator }}" export INPUT_SEPARATOR="${{ inputs.separator }}"
echo "Getting head sha..." echo "Getting head sha..."
if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $GITHUB_BASE_REF ]]; then
HEAD_SHA=$(git rev-parse HEAD^1 || true) HEAD_SHA=$(git rev-parse HEAD^1 || true)
else else
@ -65,6 +66,8 @@ runs:
HEAD_SHA=$(git rev-parse "${TARGET_BRANCH}" || true) HEAD_SHA=$(git rev-parse "${TARGET_BRANCH}" || true)
fi fi
echo "Using head sha: $HEAD_SHA..."
if [[ -z "$INPUT_FILES" ]]; then if [[ -z "$INPUT_FILES" ]]; then
echo "Getting diff..." echo "Getting diff..."
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
@ -77,6 +80,9 @@ runs:
UNKNOWN=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") UNKNOWN=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
ALL_CHANGED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") ALL_CHANGED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
ALL_MODIFIED_FILES=$(git diff --diff-filter="ACM" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//") ALL_MODIFIED_FILES=$(git diff --diff-filter="ACM" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
echo "All changed files: $ALL_CHANGED"
echo "All modified files: ALL_MODIFIED_FILES"
else else
ADDED_ARRAY=() ADDED_ARRAY=()
COPIED_ARRAY=() COPIED_ARRAY=()
@ -115,6 +121,9 @@ runs:
ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//") ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//") ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
echo "All changed files: $ALL_CHANGED"
echo "All modified files: ALL_MODIFIED_FILES"
# shellcheck disable=SC2001 # shellcheck disable=SC2001
OUTPUT_ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed "s/$INPUT_SEPARATOR/ /g") OUTPUT_ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed "s/$INPUT_SEPARATOR/ /g")
ALL_INPUT_FILES=${INPUT_FILES//\n/ } ALL_INPUT_FILES=${INPUT_FILES//\n/ }