Skip to content

Commit c237030

Browse files
committed
Add script to test for tabs in commit range
In order to prevent violations of the coding style in ompi it was decided to check any future PRs for white space violations. This script checks whether a certain commit range has introduced a tab character. See open-mpi/ompi#6831 for details. Signed-off-by: guserav <[email protected]>
1 parent 3f33779 commit c237030

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

jenkins/whitespace-checker.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (c) 2019 Hewlett Packard Enterprise. All Rights Reserved.
4+
#
5+
# Additional copyrights may follow
6+
#
7+
# Check for white space violation in a given commit range.
8+
# Run on a PR to check whether it is introducing bad white space.
9+
#
10+
11+
context=3
12+
config_file=.whitespace-checker-config.txt
13+
if [[ -r $config_file ]]; then
14+
exclude_dirs=`cat $config_file`
15+
else
16+
exclude_dirs='hwloc|libevent|pmix4x|treematch|romio'
17+
fi
18+
19+
foundTab=0
20+
for file in $(git diff --name-only $1 $2 | grep -vE "/($exclude_dirs)/" | grep -E "(\.c|\.h)$")
21+
do
22+
git diff $1 $2 -- $file | grep -C $context -E "^\+.* +"
23+
if [[ $? -eq 0 ]]
24+
then
25+
foundTab=1
26+
fi
27+
done
28+
29+
if [[ $foundTab -ne 0 ]]
30+
then
31+
exit 1
32+
fi

0 commit comments

Comments
 (0)