Skip to content

Commit be976a1

Browse files
vkuceraktf
authored andcommitted
Add detection of trailing whitespaces.
1 parent ae53b98 commit be976a1

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Find tabs in modified text files
2-
name: Tab finder
1+
# Find bad spacing in modified text files
2+
name: Space checker
33
on: [push, pull_request]
44
env:
55
MAIN_BRANCH: dev
66
jobs:
77
build:
8-
name: Tab finder
8+
name: Space checker
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout Code
@@ -18,24 +18,32 @@ jobs:
1818
git config --global user.name "Nemo" # required on some servers
1919
git remote add upstream https://github.com/AliceO2Group/AliceO2.git || exit 1
2020
git fetch upstream ${{ env.MAIN_BRANCH }} || exit 1
21-
- name: Find tabs
21+
- name: Find bad spacing
2222
run: |
23-
# Find tabs in modified text files and show where they are
24-
status=0
23+
# Find tabs and trailing whitespaces in modified text files and show where they are
24+
status_tab=0
25+
status_trail=0
2526
# Get the common ancestor of the current branch and the main upstream branch
2627
BASE_COMMIT=$(git merge-base HEAD upstream/${{ env.MAIN_BRANCH }})
27-
# loop over changed files
2828
echo "Diffing against: $BASE_COMMIT"
29+
# loop over changed files
2930
for f in $(git diff --diff-filter d --name-only $BASE_COMMIT); do
3031
# ignore binary files
3132
file -bi "$f" | grep -q "charset=binary" && continue
32-
# find tabs in file
3333
echo "Scanning file: $f"
34+
# find tabs
3435
if grep -q -P "\t" "$f"; then
35-
status=1
36+
status_tab=1
3637
echo "Found some tabs:"
37-
# print out where the tabs are
38+
# print out where they are
3839
grep -P -n -C 1 "\t" "$f"
3940
fi
41+
# find trailing whitespaces
42+
if grep -q " $" "$f"; then
43+
status_trail=2
44+
echo "Found some trailing whitespaces:"
45+
# print out where they are
46+
grep -n -C 1 " $" "$f"
47+
fi
4048
done
41-
exit $status
49+
exit $((status_tab + status_trail))

0 commit comments

Comments
 (0)