Skip to content

Commit d6ebd47

Browse files
authored
Update lint_xrefs.sh
1 parent ddd55a6 commit d6ebd47

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

scripts/lint_xrefs.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ done < <(
3434
':(exclude,glob)**/third-party/**'
3535
':(exclude,glob)**/third_party/**'
3636
)
37-
if [ $# -gt 0 ]; then
38-
paths=("$@")
37+
if [ $# -eq 2 ]; then
38+
for filename in $(git diff --name-only --unified=0 "$1...$2"); do
39+
git diff --unified=0 "$1...$2" -- "$filename" "${excludes[@]}" \
40+
| grep -E '^\+' \
41+
| grep -Ev '^\+\+\+' \
42+
| perl -nle 'print for m#'"$pattern"'#g' \
43+
| sed 's|^|'"$filename"':|'
44+
done
3945
else
40-
paths=('*')
41-
fi
42-
git --no-pager grep --no-color -I -P -o "$pattern" -- "${paths[@]}" "${excludes[@]}" \
46+
git --no-pager grep --no-color -I -P -o "$pattern" -- . "${excludes[@]}"
47+
fi \
4348
| grep -Ev 'https?://' \
4449
| sed -E \
4550
-e 's#([^:]+):\[[^]]+\]\(([^)]+)\)#\1:\2#' \

0 commit comments

Comments
 (0)