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:
18
18
timeout : 120
19
19
script : |
20
20
./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
26
26
) || {
27
27
echo
28
28
echo "URL lint failed."
@@ -43,11 +43,11 @@ jobs:
43
43
timeout : 60
44
44
script : |
45
45
./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
51
51
) || {
52
52
echo
53
53
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
66
66
while [ " $( running_jobs) " -ge " $max_jobs " ]; do
67
67
sleep 1
68
68
done
69
- done < <(
69
+ done < <(
70
70
pattern=' (?!.*@lint-ignore)(?<!git\+)(?<!\$\{)https?://(?![^/]*@)(?![^\s<>\")]*[<>\{\}\$])[^[:space:]<>")\[\]\\|]+'
71
71
excludes=(
72
72
' :(exclude,glob)**/.*'
@@ -78,12 +78,17 @@ while IFS=: read -r filepath url; do
78
78
' :(exclude,glob)**/third-party/**'
79
79
' :(exclude,glob)**/third_party/**'
80
80
)
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
83
89
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 \
87
92
| sed -E ' s/[^/[:alnum:]]+$//' \
88
93
| grep -Ev ' ://(0\.0\.0\.0|127\.0\.0\.1|localhost)([:/])' \
89
94
| 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 < <(
34
34
' :(exclude,glob)**/third-party/**'
35
35
' :(exclude,glob)**/third_party/**'
36
36
)
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
39
45
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 \
43
48
| grep -Ev ' https?://' \
44
49
| sed -E \
45
50
-e ' s#([^:]+):\[[^]]+\]\(([^)]+)\)#\1:\2#' \
You can’t perform that action at this time.
0 commit comments