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

Handle spaces in filenames #121

Merged
merged 25 commits into from
Nov 25, 2021
Merged
Changes from 10 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
16 changes: 13 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@ FILES=$(echo "${ALL_FILES[*]}" | awk '{gsub(/ /,"\n"); print $0;}' | awk -v d="|

echo "Checking for file changes: \"${FILES}\"..."

STAGED_FILES+=$(git diff --diff-filter=ACMUXTR --name-only | grep -E "(${FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
STAGED_FILES=$(git diff --diff-filter=ACMUXTR --name-only | grep -E "(${FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')

# Find unstaged changes
UNSTAGED_FILES+=$(git status --porcelain | awk '{$1=""; print $0 }' | grep -E "(${FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}'
UNSTAGED_FILES=$(git status --porcelain | awk '{$1=""; print $0 }' | grep -E "(${FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')

CHANGED_FILES=""


if [[ -n "$STAGED_FILES" && -n "$UNSTAGED_FILES" ]]; then
echo "Found staged "$STAGED_FILES" and unstaged "$UNSTAGED_FILES" file(s)..."
jackton1 marked this conversation as resolved.
Show resolved Hide resolved
CHANGED_FILES="$STAGED_FILES|$UNSTAGED_FILES"
elif [[ -n "$STAGED_FILES" && -z "$UNSTAGED_FILES" ]]; then
echo "Found staged file(s)..."
CHANGED_FILES="$STAGED_FILES"
elif [[ -n "$UNSTAGED_FILES" && -z "$STAGED_FILES" ]]; then
echo "Found unstaged file(s)..."
CHANGED_FILES="$UNSTAGED_FILES"
fi

echo "$CHANGED_FILES"

CHANGED_FILES=$(echo "$CHANGED_FILES" | awk '{gsub(/\|/,"\n"); print $0;}' | sort -u | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')

echo "$CHANGED_FILES"

if [[ -n "$CHANGED_FILES" ]]; then
echo "Found uncommited changes"
echo "---------------"
printf '%s\n' "$(echo $CHANGED_FILES | awk '{gsub(/\|/," "); print $0;}')"
printf '%s\n' "$(echo "$CHANGED_FILES" | awk '{gsub(/\|/," "); print $0;}')"
echo "---------------"
echo "::set-output name=files_changed::true"
echo "::set-output name=changed_files::$CHANGED_FILES"
Expand Down