-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow ignoring files when link checking (#2264)
* Allow ignoring files when link checking * cargo fmt * Fix tests * Remove mystery duplicate function..? * Add in some mysterious missing code..? * Simple tests for link checker file globs in config * cargo fmt * Remove comment * convert expect to error propagation * Address comments * cargo fmt
- Loading branch information
Showing
5 changed files
with
117 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use libs::globset::{Glob, GlobSet, GlobSetBuilder}; | ||
|
||
use errors::{bail, Result}; | ||
|
||
pub fn build_ignore_glob_set(ignore: &Vec<String>, name: &str) -> Result<GlobSet> { | ||
// Convert the file glob strings into a compiled glob set matcher. We want to do this once, | ||
// at program initialization, rather than for every page, for example. We arrange for the | ||
// globset matcher to always exist (even though it has to be inside an Option at the | ||
// moment because of the TOML serializer); if the glob set is empty the `is_match` function | ||
// of the globber always returns false. | ||
let mut glob_set_builder = GlobSetBuilder::new(); | ||
for pat in ignore { | ||
let glob = match Glob::new(pat) { | ||
Ok(g) => g, | ||
Err(e) => bail!("Invalid ignored_{} glob pattern: {}, error = {}", name, pat, e), | ||
}; | ||
glob_set_builder.add(glob); | ||
} | ||
Ok(glob_set_builder.build()?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod anchors; | ||
pub mod de; | ||
pub mod fs; | ||
pub mod globs; | ||
pub mod net; | ||
pub mod site; | ||
pub mod slugs; | ||
|