job: add processing blacklist to global config

This commit is contained in:
Bruno BELANYI 2021-03-30 16:11:36 +00:00
parent 209e1e58c7
commit 9de7c783ae
4 changed files with 51 additions and 0 deletions

38
Cargo.lock generated
View file

@ -56,6 +56,15 @@ dependencies = [
"opaque-debug",
]
[[package]]
name = "aho-corasick"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.40"
@ -503,10 +512,12 @@ dependencies = [
"hex",
"hmac",
"log 0.4.14",
"regex",
"rocket",
"rocket_contrib",
"serde",
"serde_json",
"serde_regex",
"serde_yaml",
"sha2",
]
@ -756,6 +767,23 @@ dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
[[package]]
name = "rocket"
version = "0.4.7"
@ -874,6 +902,16 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_regex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8136f1a4ea815d7eac4101cfd0b16dc0cb5e1fe1b8609dfd728058656b7badf"
dependencies = [
"regex",
"serde",
]
[[package]]
name = "serde_yaml"
version = "0.8.17"

View file

@ -15,9 +15,11 @@ anyhow = "1.0.40"
hex = "0.4.3"
hmac = "0.10.1"
log = "0.4.14"
regex = "1"
rocket = "0.4.7"
rocket_contrib = { version = "0.4.7", features = [ "json" ] }
serde = { version = "1.0.125", features = [ "derive" ] }
serde_json = "1.0.64"
serde_regex = "1.1.0"
serde_yaml = "0.8.17"
sha2 = "0.9.3"

View file

@ -190,6 +190,13 @@ impl Job {
}
pub(crate) fn run(&mut self, homedir: &Path, config: &GlobalSettings) -> anyhow::Result<()> {
if config
.blacklist
.iter()
.any(|re| re.is_match(&self.repo.full_name))
{
return Ok(());
}
let local_path = homedir.join(&self.repo.full_name);
assert!(local_path.is_absolute());
self.local_path = Some(local_path);

View file

@ -10,4 +10,8 @@ pub(crate) struct GlobalSettings {
/// List of remote stems to use for every repository
#[serde(default)]
pub additional_remotes: Vec<RepoUrl>,
/// List of regexes, if a repository's name matches any of the, it is not mirrored by `lohr`
/// even if it contains a `.lorh` file.
#[serde(with = "serde_regex")]
pub blacklist: Vec<regex::Regex>,
}