2021-05-21 12:39:56 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-11-24 03:05:28 +00:00
|
|
|
set -euo pipefail
|
2021-05-21 12:39:56 +00:00
|
|
|
|
2022-03-08 11:59:26 +00:00
|
|
|
INPUT_SEPARATOR="${INPUT_SEPARATOR//'%'/'%25'}"
|
2022-06-12 14:08:13 +00:00
|
|
|
INPUT_SEPARATOR="${INPUT_SEPARATOR//'.'/'%2E'}"
|
2022-03-08 11:59:26 +00:00
|
|
|
INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\n'/'%0A'}"
|
|
|
|
INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/'%0D'}"
|
|
|
|
|
2022-10-14 18:59:47 +00:00
|
|
|
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
|
2022-12-19 05:12:33 +00:00
|
|
|
DIFF=$INPUT_DIFF
|
2022-10-14 18:59:47 +00:00
|
|
|
|
2022-12-19 17:51:22 +00:00
|
|
|
OUTPUTS_EXTENSION="txt"
|
|
|
|
|
|
|
|
if [[ "$INPUT_JSON" == "true" ]]; then
|
|
|
|
OUTPUTS_EXTENSION="json"
|
|
|
|
fi
|
|
|
|
|
2022-04-28 06:08:15 +00:00
|
|
|
if [[ $INPUT_QUOTEPATH == "false" ]]; then
|
|
|
|
git config --global core.quotepath off
|
|
|
|
else
|
|
|
|
git config --global core.quotepath on
|
|
|
|
fi
|
|
|
|
|
2022-06-02 16:13:45 +00:00
|
|
|
if [[ -n $INPUT_DIFF_RELATIVE ]]; then
|
|
|
|
git config --global diff.relative "$INPUT_DIFF_RELATIVE"
|
|
|
|
fi
|
|
|
|
|
2022-11-24 01:35:30 +00:00
|
|
|
function get_dirname_max_depth() {
|
2022-11-24 01:59:55 +00:00
|
|
|
while IFS='' read -r line; do
|
2022-11-24 02:00:52 +00:00
|
|
|
local dir="$line"
|
|
|
|
local dirs=()
|
2022-11-24 01:59:55 +00:00
|
|
|
IFS='/' read -ra dirs <<<"$dir"
|
2022-11-24 01:35:30 +00:00
|
|
|
|
2022-11-24 01:59:55 +00:00
|
|
|
local max_depth=${#dirs[@]}
|
|
|
|
local input_dir_names_max_depth="${INPUT_DIR_NAMES_MAX_DEPTH:-$max_depth}"
|
2022-11-24 00:25:26 +00:00
|
|
|
|
2022-11-24 01:59:55 +00:00
|
|
|
if [[ -n "$input_dir_names_max_depth" && "$input_dir_names_max_depth" -lt "$max_depth" ]]; then
|
|
|
|
max_depth="$input_dir_names_max_depth"
|
|
|
|
fi
|
2022-11-24 00:25:26 +00:00
|
|
|
|
2022-11-24 02:56:19 +00:00
|
|
|
local output="${dirs[0]}"
|
|
|
|
local depth="1"
|
2022-11-24 00:25:26 +00:00
|
|
|
|
2022-11-24 02:56:19 +00:00
|
|
|
while [ "$depth" -lt "$max_depth" ]; do
|
2022-11-24 02:38:21 +00:00
|
|
|
output="$output/${dirs[${depth}]}"
|
2022-11-24 01:59:55 +00:00
|
|
|
depth=$((depth + 1))
|
|
|
|
done
|
2022-11-24 00:25:26 +00:00
|
|
|
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "$output"
|
|
|
|
done < <(uniq)
|
2022-11-24 00:25:26 +00:00
|
|
|
}
|
|
|
|
|
2022-12-30 05:27:08 +00:00
|
|
|
function json_output() {
|
|
|
|
JQ_ARGS="-R"
|
|
|
|
if [[ "$INPUT_JSON_RAW_FORMAT" == "true" ]]; then
|
|
|
|
JQ_ARGS="$JQ_ARGS -r"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
jq $JQ_ARGS 'split("|") | @json' | sed -r 's/^"|"$//g' | tr -s /
|
|
|
|
}
|
|
|
|
|
2022-02-23 08:39:20 +00:00
|
|
|
function get_diff() {
|
2022-10-25 21:52:44 +00:00
|
|
|
local base="$1"
|
|
|
|
local sha="$2"
|
|
|
|
local filter="$3"
|
|
|
|
|
2022-02-23 08:39:20 +00:00
|
|
|
while IFS='' read -r sub; do
|
2022-11-03 15:03:41 +00:00
|
|
|
sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | { grep '^[-]Subproject commit' || true; } | awk '{print $3}')" && exit_status=$? || exit_status=$?
|
2022-11-03 13:12:26 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 13:02:46 +00:00
|
|
|
echo "::error::Failed to get previous commit for submodule ($sub) between: $base$DIFF$sha"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-11-03 15:03:41 +00:00
|
|
|
sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | { grep '^[+]Subproject commit' || true; } | awk '{print $3}')" && exit_status=$? || exit_status=$?
|
2022-11-03 13:12:26 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 13:02:46 +00:00
|
|
|
echo "::error::Failed to get current commit for submodule ($sub) between: $base$DIFF$sha"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-02-23 08:39:20 +00:00
|
|
|
if [ -n "$sub_commit_cur" ]; then
|
2022-11-24 01:59:55 +00:00
|
|
|
(
|
|
|
|
cd "$sub" && (
|
|
|
|
# the strange magic number is a hardcoded "empty tree" commit sha
|
|
|
|
get_diff "${sub_commit_pre:-4b825dc642cb6eb9a060e54bf8d69288fbee4904}" "${sub_commit_cur}" "$filter" | awk -v r="$sub" '{ print "" r "/" $0}'
|
|
|
|
)
|
2022-02-23 08:39:20 +00:00
|
|
|
)
|
|
|
|
fi
|
|
|
|
done < <(git submodule | awk '{print $2}')
|
2022-06-12 14:08:13 +00:00
|
|
|
|
|
|
|
if [[ "$INPUT_DIR_NAMES" == "true" ]]; then
|
2022-12-19 05:12:33 +00:00
|
|
|
git diff --diff-filter="$filter" --name-only --ignore-submodules=all --no-merges "$base$DIFF$sha" | xargs -I {} dirname {} | get_dirname_max_depth | uniq && exit_status=$? || exit_status=$?
|
2022-10-21 12:58:29 +00:00
|
|
|
|
2022-11-03 13:12:26 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 12:58:29 +00:00
|
|
|
echo "::error::Failed to get changed directories between: $base$DIFF$sha"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-06-12 14:08:13 +00:00
|
|
|
else
|
2022-12-19 05:12:33 +00:00
|
|
|
git diff --diff-filter="$filter" --name-only --ignore-submodules=all --no-merges "$base$DIFF$sha" && exit_status=$? || exit_status=$?
|
2022-10-21 12:58:29 +00:00
|
|
|
|
2022-11-03 13:12:26 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 13:06:33 +00:00
|
|
|
echo "::error::Failed to get changed files between: $base$DIFF$sha"
|
2022-10-21 12:58:29 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-06-12 14:08:13 +00:00
|
|
|
fi
|
2022-05-14 21:05:44 +00:00
|
|
|
}
|
|
|
|
|
2022-05-14 21:05:44 +00:00
|
|
|
function get_renames() {
|
2022-10-25 21:52:44 +00:00
|
|
|
local base="$1"
|
|
|
|
local sha="$2"
|
|
|
|
|
2022-05-14 21:05:44 +00:00
|
|
|
while IFS='' read -r sub; do
|
2022-11-03 15:03:41 +00:00
|
|
|
sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | { grep '^[-]Subproject commit' || true; } | awk '{print $3}')" && exit_status=$? || exit_status=$?
|
2022-11-03 13:12:26 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 13:02:46 +00:00
|
|
|
echo "::error::Failed to get previous commit for submodule ($sub) between: $base$DIFF$sha"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-11-24 01:59:55 +00:00
|
|
|
sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | { grep '^[+]Subproject commit' || true; } | awk '{print $3}')" && exit_status=$? || exit_status=$?
|
2022-11-03 13:12:26 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 13:02:46 +00:00
|
|
|
echo "::error::Failed to get current commit for submodule ($sub) between: $base$DIFF$sha"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-05-14 21:05:44 +00:00
|
|
|
if [ -n "$sub_commit_cur" ]; then
|
2022-11-24 01:59:55 +00:00
|
|
|
(
|
|
|
|
cd "$sub" && (
|
|
|
|
# the strange magic number is a hardcoded "empty tree" commit sha
|
|
|
|
get_renames "${sub_commit_pre:-4b825dc642cb6eb9a060e54bf8d69288fbee4904}" "${sub_commit_cur}" | awk -v r="$sub" '{ print "" r "/" $0}'
|
|
|
|
)
|
2022-05-14 21:05:44 +00:00
|
|
|
)
|
|
|
|
fi
|
|
|
|
done < <(git submodule | awk '{print $2}')
|
2022-05-24 04:14:06 +00:00
|
|
|
|
2022-06-12 14:08:13 +00:00
|
|
|
if [[ "$INPUT_DIR_NAMES" == "true" ]]; then
|
2022-11-24 01:59:55 +00:00
|
|
|
git log --name-status --ignore-submodules=all "$base" "$sha" | { grep -E "^R" || true; } | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | get_dirname_max_depth | uniq && exit_status=$? || exit_status=$?
|
2022-10-21 12:58:29 +00:00
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 13:06:33 +00:00
|
|
|
echo "::error::Failed to get renamed directories between: $base → $sha"
|
2022-10-21 12:58:29 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-06-12 14:08:13 +00:00
|
|
|
else
|
2022-11-03 14:58:59 +00:00
|
|
|
git log --name-status --ignore-submodules=all "$base" "$sha" | { grep -E "^R" || true; } | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' && exit_status=$? || exit_status=$?
|
2022-10-21 12:58:29 +00:00
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-10-21 13:06:33 +00:00
|
|
|
echo "::error::Failed to get renamed files between: $base → $sha"
|
2022-10-21 12:58:29 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-06-12 14:08:13 +00:00
|
|
|
fi
|
2022-02-23 08:39:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-26 14:20:56 +00:00
|
|
|
echo "::group::changed-files"
|
|
|
|
|
2021-08-28 01:53:03 +00:00
|
|
|
if [[ -n $INPUT_PATH ]]; then
|
|
|
|
REPO_DIR="$GITHUB_WORKSPACE/$INPUT_PATH"
|
2022-05-30 00:32:23 +00:00
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
echo "Resolving repository path: $REPO_DIR"
|
2021-08-28 01:53:03 +00:00
|
|
|
if [[ ! -d "$REPO_DIR" ]]; then
|
2022-06-24 04:17:41 +00:00
|
|
|
echo "::error::Invalid repository path: $REPO_DIR"
|
2021-08-28 01:53:03 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
fi
|
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
echo "Retrieving changes between $INPUT_PREVIOUS_SHA ($INPUT_TARGET_BRANCH) → $INPUT_CURRENT_SHA ($INPUT_CURRENT_BRANCH)"
|
2021-05-25 04:30:19 +00:00
|
|
|
|
2022-09-25 00:35:01 +00:00
|
|
|
if [[ "$INPUT_HAS_CUSTOM_PATTERNS" == "false" ]]; then
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ "$INPUT_JSON" == "false" ]]; then
|
|
|
|
ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
DELETED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" D | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" M | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
RENAMED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
TYPE_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" T | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
UNMERGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" U | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
UNKNOWN=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" X | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
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}')
|
|
|
|
if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then
|
|
|
|
ALL_OLD_NEW_RENAMED=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
fi
|
|
|
|
else
|
2022-12-30 05:27:08 +00:00
|
|
|
ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
DELETED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" D | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" M | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
RENAMED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
TYPE_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" T | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
UNMERGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" U | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
UNKNOWN=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" X | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
|
|
|
ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then
|
2022-12-30 05:27:08 +00:00
|
|
|
ALL_OLD_NEW_RENAMED=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}' | json_output)
|
2022-08-03 20:01:40 +00:00
|
|
|
fi
|
2022-05-25 21:47:58 +00:00
|
|
|
fi
|
2021-05-21 12:39:56 +00:00
|
|
|
else
|
2022-11-03 15:03:41 +00:00
|
|
|
ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | 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" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
DELETED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" D | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" M | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
RENAMED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" R | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
TYPE_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" T | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
UNMERGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" U | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
UNKNOWN=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" X | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | 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" || true; } | 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" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
2022-05-25 21:47:58 +00:00
|
|
|
if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then
|
2022-11-03 15:03:41 +00:00
|
|
|
ALL_OLD_NEW_RENAMED=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | { grep -w -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
2022-05-25 21:47:58 +00:00
|
|
|
fi
|
2022-02-23 08:39:20 +00:00
|
|
|
|
|
|
|
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}')
|
2021-10-23 13:29:28 +00:00
|
|
|
|
2022-06-12 14:08:13 +00:00
|
|
|
if [[ -n "${ALL_CHANGED}" ]]; then
|
|
|
|
echo "::debug::Matching changed files: ${ALL_CHANGED}"
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=any_changed::true"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "any_changed=true" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-05-21 12:39:56 +00:00
|
|
|
else
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=any_changed::false"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "any_changed=false" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-05-21 12:39:56 +00:00
|
|
|
fi
|
2022-05-14 17:40:14 +00:00
|
|
|
|
2021-12-30 02:22:46 +00:00
|
|
|
OTHER_CHANGED=""
|
2021-07-17 19:13:26 +00:00
|
|
|
|
2021-12-14 07:01:31 +00:00
|
|
|
if [[ -n $ALL_OTHER_CHANGED ]]; then
|
2022-06-12 14:08:13 +00:00
|
|
|
if [[ -n "$ALL_CHANGED" ]]; then
|
2022-11-24 01:59:55 +00:00
|
|
|
OTHER_CHANGED=$(echo "${ALL_OTHER_CHANGED}|${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | sort | uniq -u | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
2021-12-14 07:01:31 +00:00
|
|
|
else
|
|
|
|
OTHER_CHANGED=$ALL_OTHER_CHANGED
|
|
|
|
fi
|
|
|
|
fi
|
2021-10-23 13:29:28 +00:00
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ "$INPUT_JSON" == "false" ]]; then
|
|
|
|
OTHER_CHANGED=$(echo "${OTHER_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
else
|
2022-12-30 05:27:08 +00:00
|
|
|
OTHER_CHANGED=$(echo "${OTHER_CHANGED}" | json_output)
|
2022-08-03 20:01:40 +00:00
|
|
|
fi
|
2021-12-14 07:01:31 +00:00
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ -n "${OTHER_CHANGED}" && "${OTHER_CHANGED}" != "[]" ]]; then
|
2022-06-11 16:51:58 +00:00
|
|
|
echo "::debug::Non Matching changed files: ${OTHER_CHANGED}"
|
2022-10-14 18:59:47 +00:00
|
|
|
|
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=only_changed::false"
|
|
|
|
echo "::set-output name=other_changed_files::$OTHER_CHANGED"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "only_changed=false" >>"$GITHUB_OUTPUT"
|
|
|
|
echo "other_changed_files=$OTHER_CHANGED" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
|
|
|
|
2022-06-12 14:08:13 +00:00
|
|
|
elif [[ -n "${ALL_CHANGED}" ]]; then
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=only_changed::true"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "only_changed=true" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-07-17 19:13:26 +00:00
|
|
|
fi
|
2021-09-05 12:22:47 +00:00
|
|
|
|
2022-02-27 17:47:28 +00:00
|
|
|
ALL_OTHER_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
2021-09-05 12:22:47 +00:00
|
|
|
|
2022-06-12 14:08:13 +00:00
|
|
|
if [[ -n "${ALL_MODIFIED}" ]]; then
|
|
|
|
echo "::debug::Matching modified files: ${ALL_MODIFIED}"
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=any_modified::true"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "any_modified=true" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-12-14 07:01:31 +00:00
|
|
|
else
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=any_modified::false"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "any_modified=false" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-12-14 07:01:31 +00:00
|
|
|
fi
|
2022-05-14 17:40:14 +00:00
|
|
|
|
2021-12-30 02:22:46 +00:00
|
|
|
OTHER_MODIFIED=""
|
2021-12-14 07:01:31 +00:00
|
|
|
|
|
|
|
if [[ -n $ALL_OTHER_MODIFIED ]]; then
|
2022-06-12 14:08:13 +00:00
|
|
|
if [[ -n "$ALL_MODIFIED" ]]; then
|
2022-11-24 01:59:55 +00:00
|
|
|
OTHER_MODIFIED=$(echo "${ALL_OTHER_MODIFIED}|${ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | sort | uniq -u | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
2021-10-23 13:29:28 +00:00
|
|
|
else
|
2021-12-14 07:01:31 +00:00
|
|
|
OTHER_MODIFIED=$ALL_OTHER_MODIFIED
|
2021-10-23 13:29:28 +00:00
|
|
|
fi
|
|
|
|
fi
|
2021-09-05 12:22:47 +00:00
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ "$INPUT_JSON" == "false" ]]; then
|
|
|
|
OTHER_MODIFIED=$(echo "${OTHER_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
else
|
2022-12-30 05:27:08 +00:00
|
|
|
OTHER_MODIFIED=$(echo "${OTHER_MODIFIED}" | json_output)
|
2022-08-03 20:01:40 +00:00
|
|
|
fi
|
2021-12-14 07:01:31 +00:00
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ -n "${OTHER_MODIFIED}" && "$OTHER_MODIFIED" != "[]" ]]; then
|
2022-06-11 16:51:58 +00:00
|
|
|
echo "::debug::Non Matching modified files: ${OTHER_MODIFIED}"
|
2022-10-14 18:59:47 +00:00
|
|
|
|
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=only_modified::false"
|
|
|
|
echo "::set-output name=other_modified_files::$OTHER_MODIFIED"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "only_modified=false" >>"$GITHUB_OUTPUT"
|
|
|
|
echo "other_modified_files=$OTHER_MODIFIED" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2022-06-12 14:08:13 +00:00
|
|
|
elif [[ -n "${ALL_MODIFIED}" ]]; then
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=only_modified::true"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "only_modified=true" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-12-14 07:01:31 +00:00
|
|
|
fi
|
|
|
|
|
2022-02-27 17:47:28 +00:00
|
|
|
ALL_OTHER_DELETED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" D | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
2021-09-05 12:22:47 +00:00
|
|
|
|
2022-06-12 14:08:13 +00:00
|
|
|
if [[ -n "${DELETED}" ]]; then
|
|
|
|
echo "::debug::Matching deleted files: ${DELETED}"
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=any_deleted::true"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "any_deleted=true" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-09-05 12:22:47 +00:00
|
|
|
else
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=any_deleted::false"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "any_deleted=false" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-09-05 12:22:47 +00:00
|
|
|
fi
|
2022-05-14 17:40:14 +00:00
|
|
|
|
2021-12-30 02:22:46 +00:00
|
|
|
OTHER_DELETED=""
|
2021-09-05 12:22:47 +00:00
|
|
|
|
2021-12-14 07:01:31 +00:00
|
|
|
if [[ -n $ALL_OTHER_DELETED ]]; then
|
2022-06-12 14:08:13 +00:00
|
|
|
if [[ -n "$DELETED" ]]; then
|
|
|
|
OTHER_DELETED=$(echo "${ALL_OTHER_DELETED}|${DELETED}" | awk '{gsub(/\|/,"\n"); print $0;}' | sort | uniq -u | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
2021-12-14 07:01:31 +00:00
|
|
|
else
|
|
|
|
OTHER_DELETED=$ALL_OTHER_DELETED
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ "$INPUT_JSON" == "false" ]]; then
|
|
|
|
OTHER_DELETED=$(echo "${OTHER_DELETED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
else
|
2022-12-30 05:27:08 +00:00
|
|
|
OTHER_DELETED=$(echo "${OTHER_DELETED}" | json_output)
|
2022-08-03 20:01:40 +00:00
|
|
|
fi
|
2021-10-23 13:29:28 +00:00
|
|
|
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ -n "${OTHER_DELETED}" && "${OTHER_DELETED}" != "[]" ]]; then
|
2022-06-11 16:51:58 +00:00
|
|
|
echo "::debug::Non Matching deleted files: ${OTHER_DELETED}"
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=only_deleted::false"
|
|
|
|
echo "::set-output name=other_deleted_files::$OTHER_DELETED"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "only_deleted=false" >>"$GITHUB_OUTPUT"
|
|
|
|
echo "other_deleted_files=$OTHER_DELETED" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2022-06-12 14:08:13 +00:00
|
|
|
elif [[ -n "${DELETED}" ]]; then
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=only_deleted::true"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "only_deleted=true" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2021-09-05 12:22:47 +00:00
|
|
|
fi
|
2022-08-03 20:01:40 +00:00
|
|
|
if [[ "$INPUT_JSON" == "false" ]]; then
|
|
|
|
ADDED=$(echo "${ADDED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
COPIED=$(echo "${COPIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
DELETED=$(echo "${DELETED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
MODIFIED=$(echo "${MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
RENAMED=$(echo "${RENAMED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
TYPE_CHANGED=$(echo "${TYPE_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
UNMERGED=$(echo "${UNMERGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
UNKNOWN=$(echo "${UNKNOWN}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
|
|
|
|
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}')
|
|
|
|
else
|
2022-12-30 05:27:08 +00:00
|
|
|
ADDED=$(echo "${ADDED}" | json_output)
|
|
|
|
COPIED=$(echo "${COPIED}" | json_output)
|
|
|
|
DELETED=$(echo "${DELETED}" | json_output)
|
|
|
|
MODIFIED=$(echo "${MODIFIED}" | json_output)
|
|
|
|
RENAMED=$(echo "${RENAMED}" | json_output)
|
|
|
|
TYPE_CHANGED=$(echo "${TYPE_CHANGED}" | json_output)
|
|
|
|
UNMERGED=$(echo "${UNMERGED}" | json_output)
|
|
|
|
UNKNOWN=$(echo "${UNKNOWN}" | json_output)
|
|
|
|
ALL_CHANGED_AND_MODIFIED=$(echo "${ALL_CHANGED_AND_MODIFIED}" | json_output)
|
|
|
|
ALL_CHANGED=$(echo "${ALL_CHANGED}" | json_output)
|
|
|
|
ALL_MODIFIED=$(echo "${ALL_MODIFIED}" | json_output)
|
2022-08-03 20:01:40 +00:00
|
|
|
fi
|
2021-05-21 12:39:56 +00:00
|
|
|
fi
|
|
|
|
|
2022-06-11 16:51:58 +00:00
|
|
|
echo "::debug::Added files: $ADDED"
|
|
|
|
echo "::debug::Copied files: $COPIED"
|
|
|
|
echo "::debug::Deleted files: $DELETED"
|
|
|
|
echo "::debug::Modified files: $MODIFIED"
|
|
|
|
echo "::debug::Renamed files: $RENAMED"
|
|
|
|
echo "::debug::Type Changed files: $TYPE_CHANGED"
|
|
|
|
echo "::debug::Unmerged files: $UNMERGED"
|
|
|
|
echo "::debug::Unknown files: $UNKNOWN"
|
|
|
|
echo "::debug::All changed and modified files: $ALL_CHANGED_AND_MODIFIED"
|
|
|
|
echo "::debug::All changed files: $ALL_CHANGED"
|
|
|
|
echo "::debug::All modified files: $ALL_MODIFIED"
|
2022-05-25 21:47:58 +00:00
|
|
|
if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then
|
2022-06-11 16:51:58 +00:00
|
|
|
echo "::debug::All old & new renamed files: $ALL_OLD_NEW_RENAMED"
|
2022-05-25 21:47:58 +00:00
|
|
|
fi
|
2021-09-04 13:08:20 +00:00
|
|
|
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=added_files::$ADDED"
|
|
|
|
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=type_changed_files::$TYPE_CHANGED"
|
|
|
|
echo "::set-output name=unmerged_files::$UNMERGED"
|
|
|
|
echo "::set-output name=unknown_files::$UNKNOWN"
|
|
|
|
echo "::set-output name=all_changed_and_modified_files::$ALL_CHANGED_AND_MODIFIED"
|
|
|
|
echo "::set-output name=all_changed_files::$ALL_CHANGED"
|
|
|
|
echo "::set-output name=all_modified_files::$ALL_MODIFIED"
|
2022-12-19 17:51:22 +00:00
|
|
|
echo "::set-output name=outputs_extension::$OUTPUTS_EXTENSION"
|
2022-10-14 18:59:47 +00:00
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
cat <<EOF >>"$GITHUB_OUTPUT"
|
2022-10-12 18:35:11 +00:00
|
|
|
added_files=$ADDED
|
|
|
|
copied_files=$COPIED
|
|
|
|
deleted_files=$DELETED
|
|
|
|
modified_files=$MODIFIED
|
|
|
|
renamed_files=$RENAMED
|
|
|
|
type_changed_files=$TYPE_CHANGED
|
|
|
|
unmerged_files=$UNMERGED
|
|
|
|
unknown_files=$UNKNOWN
|
|
|
|
all_changed_and_modified_files=$ALL_CHANGED_AND_MODIFIED
|
|
|
|
all_changed_files=$ALL_CHANGED
|
|
|
|
all_modified_files=$ALL_MODIFIED
|
2022-12-19 17:51:22 +00:00
|
|
|
outputs_extension=$OUTPUTS_EXTENSION
|
2022-10-12 18:35:11 +00:00
|
|
|
EOF
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
|
|
|
|
2022-05-25 21:47:58 +00:00
|
|
|
if [[ $INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES == "true" ]]; then
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=all_old_new_renamed_files::$ALL_OLD_NEW_RENAMED"
|
|
|
|
else
|
2022-11-24 01:59:55 +00:00
|
|
|
echo "all_old_new_renamed_files=$ALL_OLD_NEW_RENAMED" >>"$GITHUB_OUTPUT"
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2022-05-25 21:47:58 +00:00
|
|
|
fi
|
2021-06-26 14:20:56 +00:00
|
|
|
|
2022-12-30 05:27:08 +00:00
|
|
|
echo "::endgroup::"
|