Skip to content

Add recipe for partial link checking #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/code-reviews/recipes/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@ To automate link check in your markdown files add `lycheeverse/lychee-action` ac

More information about this action options can be found at [`lychee-action` home page](https://github.com/lycheeverse/lychee-action).

> Tip: When triggered on a PR, you can skip checking links that already exist in the main branch. This approach saves time and helps avoid rate limiting issues. Example implementation based on [this recipe](https://github.com/lycheeverse/lychee-action/issues/238#issuecomment-2638242300):
>
> ```bash
> set -euxo pipefail
>
> # Remember the current commit
> currentCommit=$(git rev-parse HEAD)
>
> # Switch to the commit in main from which the current commit has branched
> git fetch origin main
> git switch --detach $(git merge-base HEAD refs/remotes/origin/main)
>
> # Collect all links that already existed in main.
> # Format them as regular expressions (by escaping special characters) and append to .lycheeignore in order to not check them again.
> lychee --dump --include-fragments . | grep '^http' | sed 's/[.^$*+?()[{|\]/\\&/g' | sed 's/^/^/; s/$/$/' >> .lycheeignore
>
> # Switch back to the original commit
> git switch --detach "$currentCommit"
>
> # Run lychee that will use the updated .lycheeignore file
> lychee -f detailed --include-fragments .
> ```

## Code Review Checklist

In addition to the [Code Review Checklist](../process-guidance/reviewer-guidance.md) you should also look for these documentation specific code review items
Expand Down