Skip to content

Commit

Permalink
Updated list of changed_files to include output from git (#79)
Browse files Browse the repository at this point in the history
* Updated list of changed_files to include output from git

* Update entrypoint.sh
  • Loading branch information
jackton1 committed Oct 4, 2021
1 parent 79e45e8 commit 25267f5
Showing 1 changed file with 17 additions and 15 deletions.
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

0 comments on commit 25267f5

Please sign in to comment.