diff --git a/.github/scripts/lintEditedFiles.sh b/.github/scripts/lintEditedFiles.sh index a36a785d1..bba10b261 100755 --- a/.github/scripts/lintEditedFiles.sh +++ b/.github/scripts/lintEditedFiles.sh @@ -5,16 +5,15 @@ git fetch origin main echo "Fetched" # Use a conditional to check if there are edited files -if EDITED_FILES=$(git diff HEAD origin/main --name-only --diff-filter=d | grep "\.swift" | grep -v "\.swiftlint\.yml" | xargs echo | tr ' ' ','); then +# This command will list the deleted files in your Git repository that have a ".swift" file extension, but it excludes files with the name ".swiftlint.yml" and converts the list into a comma-separated string. +# Use a conditional to check if there are edited files +if EDITED_FILES=$(git diff HEAD origin/main --name-only --diff-filter=d | grep "\.swift" | grep -v "\.swiftlint\.yml"); then echo "Got edited files" - echo $EDITED_FILES - - # Check if EDITED_FILES is empty or null - if [ -z "$EDITED_FILES" ]; then - echo "No edited .swift files found." - else - swiftlint lint $EDITED_FILES | sed -E 's/^(.*):([0-9]+):([0-9]+): (warning|error|[^:]+): (.*)/::\4 title=Lint error,file=\1,line=\2,col=\3::\5\n\1:\2:\3/' - fi + # Use an array to store file paths + EDITED_FILES=($EDITED_FILES) + for FILE in "${EDITED_FILES[@]}"; do + swiftlint lint "$FILE" | sed -E 's/^(.*):([0-9]+):([0-9]+): (warning|error|[^:]+): (.*)/::\4 title=Lint error,file=\1,line=\2,col=\3::\5\n\1:\2:\3/' + done else echo "No changes in .swift files found." fi