Skip to content

Update configuration. Update Run 2 conversion. #1003

Update configuration. Update Run 2 conversion.

Update configuration. Update Run 2 conversion. #1003

Workflow file for this run

---
# Find bad spacing in modified text files
name: Space checker
on: [push, pull_request]
permissions: {}
env:
MAIN_BRANCH: master
jobs:
build:
name: Space checker
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed to get the full history
- name: Find bad spacing
run: |
# Find tabs and trailing whitespaces in modified text files and show where they are
status_tab=0
status_trail=0
# loop over changed files
# Diff against the common ancestor of the source branch and the main branch.
for f in $(git diff --diff-filter d --name-only origin/${{ env.MAIN_BRANCH }}...); do
# ignore binary files
file -bi "$f" | grep -q "charset=binary" && continue
echo "Scanning file: $f"
# find tabs
if grep -q -P "\t" "$f"; then
status_tab=1
echo "::error::Found some tabs:"
# print out where they are
#grep -P -n "\t" "$f"
awk 'i=index($0, "\t") {printf "%i (col. %i): %s\n", NR, i, $0}' "$f"
fi
# find trailing whitespaces
if grep -q " $" "$f"; then
status_trail=2
echo "::error::Found some trailing whitespaces:"
# print out where they are
grep -n " $" "$f"
fi
done
status=$((status_tab + status_trail))
if [ "$status" -ne 0 ]; then
# shellcheck disable=2028
echo "::warning::Fix the errors in your editor (or with a command)
Command tips:
- Get list of files you changed: git diff --diff-filter d --name-only ${{ env.MAIN_BRANCH }}...
- Replace each tab with two spaces: sed -i 's/\\t/ /g' <files>
- Remove trailing whitespaces: sed -i 's/[[:space:]]*$//' <files>"
echo "::warning::To avoid these errors, configure your editor to:
- Emit spaces when the Tab key is pressed.
- Display whitespace characters.
- Replace tabs with spaces and remove trailing whitespaces when a file is saved."
fi
exit $status