Skip to content

Commit a3a9d1a

Browse files
erichermanixuz
andcommitted
default is "main" branch, not "develop"
fixes #112 Co-authored-by: Anton Wiklund <[email protected]> Signed-off-by: Eric Herman <[email protected]>
1 parent 1f5fab5 commit a3a9d1a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

script/check-new-links.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
if [ -z "$VERBOSE" ]; then VERBOSE=0; fi
4+
if [ "$VERBOSE" -gt 1 ]; then set -x; fi
5+
set -e
6+
set -o pipefail
7+
38
# This script is referenced by .github/workflows/test.yml which executes on
49
# each pull request.
510

@@ -16,11 +21,20 @@ SKIP_PATTERNS=(
1621
'http://localhost' # local host
1722
)
1823

19-
if [ "_${VERBOSE}_" == "__" ]; then VERBOSE=0; fi
24+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
25+
REMOTE=$(git config branch.$BRANCH.remote || echo "origin")
26+
git fetch --depth=1 $REMOTE main
27+
GIT_DIFF_OUTPUT=$(git diff $REMOTE/main)
28+
29+
# the greps are allowed to "fail" without matching
30+
URLS=$(echo "$GIT_DIFF_OUTPUT" \
31+
| grep '^+' \
32+
| grep --extended-regexp --only-matching \
33+
'(http|https)://[^ )"><]+' \
34+
|| true
35+
)
2036

21-
for URL in $(git diff develop |
22-
grep '^+' |
23-
grep -Eo '(http|https)://[^ )"><]+'); do
37+
for URL in $URLS; do
2438
SKIP_URL=0
2539
for PATTERN in "${SKIP_PATTERNS[@]}"; do
2640
if echo "$URL" | grep --quiet --extended-regexp "$PATTERN"

0 commit comments

Comments
 (0)