11#! /usr/bin/env bash
2-
32# SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
43# SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
54# SPDX-License-Identifier: BSD-3-Clause
6-
5+ #
76# Usage: link_check.sh <SeqAn3 root directory>
87# Will output the status of links in the repository.
98#
1312# The general workflow is to first run the script and then check the non-working links by searching the occurrence
1413# within the codebase and verifying that they are indeed broken.
1514
15+ COUNT=0
1616do_check ()
1717{
18- RESPONSE=$( curl --http2 -Is -A ' Mozilla/5.0' $1 ) # HTTP2 is the default.
19- if ! [[ " $RESPONSE " =~ ^HTTP.* ]]; then # If this does not work,
20- RESPONSE=$( curl --http1.1 -Is -A ' Mozilla/5.0' $1 ) # fall back to HTTP1.1.
18+ (( COUNT++ ))
19+ RESPONSE=$( curl --http2 -Is -A ' Mozilla/5.0' " $1 " ) # HTTP2 is the default.
20+ if ! [[ " ${RESPONSE} " =~ ^HTTP.* ]]; then # If this does not work,
21+ RESPONSE=$( curl --http1.1 -Is -A ' Mozilla/5.0' " $1 " ) # fall back to HTTP1.1.
2122 fi
2223
23- HEADER=($( echo $ RESPONSE | head -1) ); # May look like: HTTP/2 200
24+ HEADER=($( echo " ${ RESPONSE} " | head -1) ); # May look like: HTTP/2 200
2425 STATUS=${HEADER[1]}
26+ echo -n " [${COUNT} ] "
2527 case " $STATUS " in
26- 200) echo " Link OK :" $1 ;;
27- 301) echo " Link PERM MOVED :" $1 ;;
28- 302) echo " Link TEMP MOVED :" $1 ;;
29- 404) echo " Link BROKE :" $1 ;;
30- 429) sleep 5; do_check $1 ;;
31- * ) echo " Link STATUS" $ STATUS " : " $1 ;;
28+ 200) echo " Link OK : $1 " ;;
29+ 301) echo " Link PERM MOVED : $1 " ;;
30+ 302) echo " Link TEMP MOVED : $1 " ;;
31+ 404) echo " Link BROKE : $1 " ;;
32+ 429) sleep 5; do_check " $1 " ;;
33+ * ) echo " Link STATUS ${ STATUS} : $1 " ;;
3234 esac
3335}
3436
35- if [[ $# -ne 1 ]]; then
36- echo " Usage: link_check.sh <SeqAn3 root directory>"
37+ if [[ $# -ne 1 ]] && [[ $# -ne 2 ]] ; then
38+ echo " Usage: link_check.sh <SeqAn3 root directory> <Skip first n=0 entries> "
3739 exit 1
3840fi
3941
@@ -48,7 +50,10 @@ if [[ ! -f $1/include/seqan3/version.hpp ]]; then
4850 exit 1
4951fi
5052
51- for URL in $( grep -ohr --exclude-dir={.git,submodules} " https*://[a-zA-Z0-9./#+?=_%:-]*[a-zA-Z0-9/#+?=_%:-]" $1 | sort | uniq)
53+ SKIP=" ${2:- 0} "
54+ COUNT=$(( COUNT + SKIP))
55+
56+ for URL in $( grep -ohr --exclude-dir={.git,.vscode,build} " https*://[a-zA-Z0-9./#+?=_%:-]*[a-zA-Z0-9/#+?=_%:-]" " $1 " | sort | uniq | tail -n +" ${SKIP} " )
5257do
53- do_check $ URL
58+ do_check " ${ URL} "
5459done
0 commit comments