| 
1 | 1 | #!/usr/bin/env bash  | 
2 | 2 | #MISE description="Lint links in modified files"  | 
3 | 3 | 
 
  | 
4 |  | -set -ex  | 
 | 4 | +set -e  | 
5 | 5 | 
 
  | 
6 | 6 | #USAGE flag "--base <base>" help="base branch to compare against" default="origin/main"  | 
7 | 7 | #USAGE flag "--head <head>" help="head branch to compare against" default=""  | 
 | 8 | +#USAGE flag "--event <event>" help="PR name" default="pull_request"  | 
8 | 9 | 
 
  | 
9 | 10 | if [ "$usage_head" == "''" ]; then  | 
10 | 11 |   usage_head=""  | 
11 | 12 | fi  | 
12 | 13 | 
 
  | 
13 |  | -# Using lychee's default extension filter here to match when it runs against all files  | 
14 |  | -# Note: --diff-filter=d filters out deleted files  | 
15 |  | -modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head \  | 
16 |  | -                  | grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \  | 
17 |  | -                  | tr '\n' ' ' || true)  | 
18 |  | - | 
19 | 14 | # Check if lychee config was modified  | 
20 | 15 | config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head \  | 
21 |  | -                  | grep -E '^(\.github/config/lychee\.toml|mise\.toml)$' || true)  | 
 | 16 | +                  | grep -E '^(\.github/config/lychee\.toml|.mise/tasks/lint|mise\.toml)$' || true)  | 
22 | 17 | 
 
  | 
23 |  | -if [ -z "$modified_files" ] && [ -z "$config_modified" ] ; then  | 
24 |  | -  echo "No modified files and no config changes, skipping link linting."  | 
 | 18 | +if [ -n "$config_modified" ] ; then  | 
 | 19 | +  echo "config changes, checking all files."  | 
 | 20 | +  mise run lint:links  | 
 | 21 | +elif [ "$usage_event" != "pull_request" ] ; then  | 
 | 22 | +  echo "Not a PR - skipping link linting."  | 
25 | 23 |   exit 0  | 
 | 24 | +else  | 
 | 25 | +  # Using lychee's default extension filter here to match when it runs against all files  | 
 | 26 | +  # Note: --diff-filter=d filters out deleted files  | 
 | 27 | +  modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head \  | 
 | 28 | +                    | grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \  | 
 | 29 | +                    | tr '\n' ' ' || true)  | 
 | 30 | + | 
 | 31 | +  if [ -z "$modified_files" ]; then  | 
 | 32 | +    echo "No modified files, skipping link linting."  | 
 | 33 | +    exit 0  | 
 | 34 | +  fi  | 
 | 35 | + | 
 | 36 | +  mise run lint:links $modified_files  | 
26 | 37 | fi  | 
27 | 38 | 
 
  | 
28 |  | -mise run lint:links $modified_files  | 
 | 
0 commit comments