File tree Expand file tree Collapse file tree 3 files changed +31
-21
lines changed
Expand file tree Collapse file tree 3 files changed +31
-21
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ jobs:
1818 timeout : 120
1919 script : |
2020 ./scripts/lint_urls.sh $(
21- { [ "${{ github.event_name }}" = "pull_request" ] \
22- && git diff --name-only "${{ github.event.pull_request.base.sha }}... ${{ github.event.pull_request.head.sha }}"; } \
23- || \
24- { [ "${{ github.event_name }}" = "push" ] \
25- && git diff --name-only "${{ github.event.before }}...${{ github.sha }}"; }
21+ if [ "${{ github.event_name }}" = "pull_request" ]; then
22+ echo "${{ github.event.pull_request.base.sha }}" " ${{ github.event.pull_request.head.sha }}"
23+ else
24+ echo "${{ github.event.before }}" "${{ github.sha }}"
25+ fi
2626 ) || {
2727 echo
2828 echo "URL lint failed."
@@ -43,11 +43,11 @@ jobs:
4343 timeout : 60
4444 script : |
4545 ./scripts/lint_xrefs.sh $(
46- { [ "${{ github.event_name }}" = "pull_request" ] \
47- && git diff --name-only "${{ github.event.pull_request.base.sha }}... ${{ github.event.pull_request.head.sha }}"; } \
48- || \
49- { [ "${{ github.event_name }}" = "push" ] \
50- && git diff --name-only "${{ github.event.before }}...${{ github.sha }}"; }
46+ if [ "${{ github.event_name }}" = "pull_request" ]; then
47+ echo "${{ github.event.pull_request.base.sha }}" " ${{ github.event.pull_request.head.sha }}"
48+ else
49+ echo "${{ github.event.before }}" "${{ github.sha }}"
50+ fi
5151 ) || {
5252 echo
5353 echo "Xref lint failed."
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ while IFS=: read -r filepath url; do
6666 while [ " $( running_jobs) " -ge " $max_jobs " ]; do
6767 sleep 1
6868 done
69- done < <(
69+ done < <(
7070 pattern=' (?!.*@lint-ignore)(?<!git\+)(?<!\$\{)https?://(?![^/]*@)(?![^\s<>\")]*[<>\{\}\$])[^[:space:]<>")\[\]\\|]+'
7171 excludes=(
7272 ' :(exclude,glob)**/.*'
@@ -78,12 +78,17 @@ while IFS=: read -r filepath url; do
7878 ' :(exclude,glob)**/third-party/**'
7979 ' :(exclude,glob)**/third_party/**'
8080 )
81- if [ $# -gt 0 ]; then
82- paths=(" $@ " )
81+ if [ $# -eq 2 ]; then
82+ for filename in $( git diff --name-only --unified=0 " $1 ...$2 " ) ; do
83+ git diff --unified=0 " $1 ...$2 " -- " $filename " " ${excludes[@]} " \
84+ | grep -E ' ^\+' \
85+ | grep -Ev ' ^\+\+\+' \
86+ | perl -nle ' print for m#' " $pattern " ' #g' \
87+ | sed ' s|^|' " $filename " ' :|'
88+ done
8389 else
84- paths=(' *' )
85- fi
86- git --no-pager grep --no-color -I -P -o " $pattern " -- " ${paths[@]} " " ${excludes[@]} " \
90+ git --no-pager grep --no-color -I -P -o " $pattern " -- . " ${excludes[@]} "
91+ fi \
8792 | sed -E ' s/[^/[:alnum:]]+$//' \
8893 | grep -Ev ' ://(0\.0\.0\.0|127\.0\.0\.1|localhost)([:/])' \
8994 | grep -Ev ' ://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' \
Original file line number Diff line number Diff 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#' \
You can’t perform that action at this time.
0 commit comments