Skip to content

Commit 2633d64

Browse files
author
thk123
committed
Also include errors assoicated with line 0 (e.g. copyright errors).
To do this we need to not error exit if the grep fails to find any valid lines. We still care about these files (this can happen if, for example, only lines are removed from the file).
1 parent 1bd4476 commit 2633d64

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

scripts/run_lint.sh

+10-14
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,16 @@ IFS=$'\n'
3737
are_errors=0
3838

3939
for file in $diff_files; do
40-
# We first filter only the lines that start with a commit hash
41-
# Then we filter out the ones that come from the start commit
42-
modified_lines=`git blame $git_start..$git_end --line-porcelain $file | grep -E "^[0-9a-f]{40}" | grep -v "$blame_grep_filter"`
40+
# We build another grep filter the output of the linting script
41+
lint_grep_filter="^("
4342

44-
if [ -z "$modified_lines" ]
45-
then
46-
# No modified lines in this file (perhaps only lines have been deleted)
47-
# So we bail on reporting errors on this file
48-
continue
49-
fi
43+
# Include line 0 errors (e.g. copyright)
44+
lint_grep_filter+=$file
45+
lint_grep_filter+=":0"
5046

51-
# Next we build another grep filter the output of the linting script
52-
lint_grep_filter="^("
47+
# We first filter only the lines that start with a commit hash
48+
# Then we filter out the ones that come from the start commit
49+
modified_lines=`git blame $git_start..$git_end --line-porcelain $file | grep -E "^[0-9a-f]{40}" | { grep -v "$blame_grep_filter" || true; }`
5350

5451
# For each modified line we find the line number
5552
for line in $modified_lines; do
@@ -66,13 +63,12 @@ for file in $diff_files; do
6663

6764
# Add the line filter on to the grep expression as we want
6865
# lines that match any of the line filters
69-
lint_grep_filter+=$LINE_FILTER
7066
lint_grep_filter+="|"
67+
lint_grep_filter+=$LINE_FILTER
7168
fi
7269
done
7370

74-
# Knock off the final pipe and add the closing bracket
75-
lint_grep_filter=${lint_grep_filter::-1}
71+
# Add the closing bracket
7672
lint_grep_filter+=")"
7773

7874
# Run the linting script and filter by the filter we've build

0 commit comments

Comments
 (0)