Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated list of changed_files to include output from git #79

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@ CHANGED_FILES=()
for path in ${INPUT_FILES}
do
echo "Checking for file changes: \"${path}\"..."
MODIFIED_FILE=$(git diff --diff-filter=ACMUXTR --name-only | grep -E "(${path})" || true)

if [[ -z $MODIFIED_FILE ]]; then
# Find unstaged changes
MODIFIED_FILE=$(git status --porcelain | awk '{ print $2 }' | grep -E "(${path})" || true)
fi

if [[ -n ${MODIFIED_FILE} ]]; then
echo "Found uncommited changes at: ${path}"
CHANGED_FILES+=("${path}")
else
echo "No changes found at: ${path}"
fi
IFS=" " read -r -a ALL_CHANGED_FILES <<< "$(git diff --diff-filter=ACMUXTR --name-only | grep -E "(${path})" || true)"
# Find unstaged changes
IFS=" " read -r -a UNSTAGED_FILES <<< "$(git status --porcelain | awk '{ print $2 }' | grep -E "(${path})" || true)"
CHANGED_FILES+=("${ALL_CHANGED_FILES[@]}" "${UNSTAGED_FILES[@]}")
done

if [[ -z ${CHANGED_FILES} ]]; then
IFS=" " read -r -a UNIQUE_CHANGED_FILES <<< "$(echo "${CHANGED_FILES[@]}" | tr " " "\n" | sort -u | tr "\n" " ")"

if [[ -n "${UNIQUE_CHANGED_FILES[*]}" ]]; then
echo "Found uncommited changes"
echo "---------------"
printf '%s\n' "${UNIQUE_CHANGED_FILES[@]}"
echo "---------------"
else
echo "No changes found."
fi

if [[ -z "${UNIQUE_CHANGED_FILES[*]}" ]]; then
echo "::set-output name=files_changed::false"
else
echo "::set-output name=files_changed::true"
echo "::set-output name=changed_files::${CHANGED_FILES}"
echo "::set-output name=changed_files::${UNIQUE_CHANGED_FILES[*]}"
fi

git remote remove temp_verify_changed_files
Expand Down