fixup! [#64] Implement copy/paste protection checks

Fix tests
This commit is contained in:
Yuri Romanowski 2022-12-23 19:10:13 +05:00
parent a844583bb9
commit fd71f9798f
No known key found for this signature in database
GPG Key ID: 9244B9434C595CCA
3 changed files with 59 additions and 15 deletions

View File

@ -86,7 +86,9 @@ defaultAction Options{..} = do
{ cNetworking = addNetworkingOptions (cNetworking config) oNetworkingOptions }
verifyRepo rw fullConfig oMode oRoot repoInfo
whenJust (nonEmpty copyPasteErrors) reportCopyPasteErrors
whenJust (nonEmpty copyPasteErrors) $ \errs -> do
reportCopyPasteErrors errs
fmt "\n"
case verifyErrors verifyRes of
Nothing | null scanErrs -> fmtLn "All repository links are valid."
Nothing -> exitFailure

View File

@ -23,26 +23,67 @@
- anchor: -
➥ In file second-file.md
reference (relative) at src:24:1-29:
- text: "fdw"
- link: ./first-file.md
- anchor: chor
reference (relative) at src:23:1-33:
- text: "fubarw"
- link: ./nonexistent-file.md
- anchor: -
is possibly a bad copy paste of
reference (relative) at src:23:1-32:
- text: "ff-cho"
- link: ./first-file.md
- anchor: chor
reference (relative) at src:24:1-36:
- text: "nonexfile"
- link: ./nonexistent-file.md
- anchor: -
➥ In file second-file.md
reference (external) at src:29:1-28:
reference (relative) at src:25:1-30:
- text: "fdw"
- link: ./nonexistent-file.md
- anchor: -
is possibly a bad copy paste of
reference (relative) at src:24:1-36:
- text: "nonexfile"
- link: ./nonexistent-file.md
- anchor: -
➥ In file second-file.md
reference (external) at src:30:1-28:
- text: "gitlab"
- link: https://github.com
- anchor: -
is possibly a bad copy paste of
reference (external) at src:28:1-28:
reference (external) at src:29:1-28:
- text: "github"
- link: https://github.com
- anchor: -
Possible copy/paste errors dumped, 4 in total.
All repository links are valid.
Possible copy/paste errors dumped, 5 in total.
=== Invalid references found ===
➥ In file second-file.md
bad reference (relative) at src:23:1-33:
- text: "fubarw"
- link: ./nonexistent-file.md
- anchor: -
File does not exist:
nonexistent-file.md
➥ In file second-file.md
bad reference (relative) at src:24:1-36:
- text: "nonexfile"
- link: ./nonexistent-file.md
- anchor: -
File does not exist:
nonexistent-file.md
➥ In file second-file.md
bad reference (relative) at src:25:1-30:
- text: "fdw"
- link: ./nonexistent-file.md
- anchor: -
File does not exist:
nonexistent-file.md
Invalid references dumped, 3 in total.

View File

@ -20,8 +20,9 @@
<!-- These ones are reported because -->
<!-- ff-cho is a subsequence of link+anchor -->
[ ff-cho](./first-file.md#chor)
[ fdw](./first-file.md#chor)
[ fubarw](./nonexistent-file.md)
[ nonexfile](./nonexistent-file.md)
[ fdw](./nonexistent-file.md)
<!-- check external links -->