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", "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]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.40" version = "1.0.40"
@ -503,10 +512,12 @@ dependencies = [
"hex", "hex",
"hmac", "hmac",
"log 0.4.14", "log 0.4.14",
"regex",
"rocket", "rocket",
"rocket_contrib", "rocket_contrib",
"serde", "serde",
"serde_json", "serde_json",
"serde_regex",
"serde_yaml", "serde_yaml",
"sha2", "sha2",
] ]
@ -756,6 +767,23 @@ dependencies = [
"bitflags", "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]] [[package]]
name = "rocket" name = "rocket"
version = "0.4.7" version = "0.4.7"
@ -874,6 +902,16 @@ dependencies = [
"serde", "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]] [[package]]
name = "serde_yaml" name = "serde_yaml"
version = "0.8.17" version = "0.8.17"

View file

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

View file

@ -190,6 +190,13 @@ impl Job {
} }
pub(crate) fn run(&mut self, homedir: &Path, config: &GlobalSettings) -> anyhow::Result<()> { 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); let local_path = homedir.join(&self.repo.full_name);
assert!(local_path.is_absolute()); assert!(local_path.is_absolute());
self.local_path = Some(local_path); 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 /// List of remote stems to use for every repository
#[serde(default)] #[serde(default)]
pub additional_remotes: Vec<RepoUrl>, 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>,
} }