Skip to content

Commit 801b60a

Browse files
author
Konstantin Gukov
committed
Add recipe for partial link checking
1 parent 54a285d commit 801b60a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/code-reviews/recipes/markdown.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,29 @@ To automate link check in your markdown files add `lycheeverse/lychee-action` ac
129129

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

132+
> 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):
133+
>
134+
> ```bash
135+
> set -euxo pipefail
136+
>
137+
> # Remember the current commit
138+
> currentCommit=$(git rev-parse HEAD)
139+
>
140+
> # Switch to the commit in main from which the current commit has branched
141+
> git fetch origin main
142+
> git switch --detach $(git merge-base HEAD refs/remotes/origin/main)
143+
>
144+
> # Collect all links that already existed in main.
145+
> # Format them as regular expressions (by escaping special characters) and append to .lycheeignore in order to not check them again.
146+
> lychee --dump --include-fragments . | grep '^http' | sed 's/[.^$*+?()[{|\]/\\&/g' | sed 's/^/^/; s/$/$/' >> .lycheeignore
147+
>
148+
> # Switch back to the original commit
149+
> git switch --detach "$currentCommit"
150+
>
151+
> # Run lychee that will use the updated .lycheeignore file
152+
> lychee -f detailed --include-fragments .
153+
> ```
154+
132155
## Code Review Checklist
133156

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

0 commit comments

Comments
 (0)