Skip to content

Commit

Permalink
Fix edited file linter script
Browse files Browse the repository at this point in the history
  • Loading branch information
okhan-okbay-cko committed Oct 23, 2023
1 parent 0b349fd commit 07b4f7b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions .github/scripts/lintEditedFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 07b4f7b

Please sign in to comment.