Sha256: 7a8cbf599ba1b00ef32dc196ba9439f120417b8824e7725bb9f4e3f1d0bbb574

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

#!/usr/bin/env bash

bad_links=("controlplane.com/shakacode" "https://docs.controlplane.com")
proper_links=("shakacode.controlplane.com" "https://shakadocs.controlplane.com")

bold=$(tput bold)
normal=$(tput sgr0)

exit_status=0
accumulated_results=""
seen_bad_links_indexes=()

for ((idx = 0; idx < ${#bad_links[@]}; idx++)); do
    results=$(git grep \
        --recursive \
        --line-number \
        --fixed-strings \
        --break \
        --heading \
        --color=always -- \
        "${bad_links[idx]}" \
        ':!script/check_cpln_links' '*.md')

    # Line would become really unwieldly if everything was mushed into the
    # conditional, so let's ignore this check here.
    # shellcheck disable=SC2181
    if [ $? -eq 0 ]; then
        accumulated_results+="$results"
        seen_bad_links_indexes+=("$idx")
        exit_status=1
    fi
done

if [ "$exit_status" -eq 1 ]; then
    echo "${bold}[!] Found the following bad links:${normal}"
    echo ""
    echo "$accumulated_results"
    echo ""
    echo "${bold}[*] Please update accordingly:${normal}"
    for bad_link_index in "${seen_bad_links_indexes[@]}"; do
        echo "  ${bad_links[bad_link_index]} -> ${proper_links[bad_link_index]}"
    done
fi

exit "$exit_status"

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
cpflow-4.0.1 script/check_cpln_links
cpflow-4.0.0 script/check_cpln_links
cpflow-3.0.1 script/check_cpln_links
cpflow-3.0.0 script/check_cpln_links
cpl-2.2.4 script/check_cpln_links
cpl-2.2.2 script/check_cpln_links
cpl-2.2.1 script/check_cpln_links
cpl-2.2.0 script/check_cpln_links