summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-06-07 16:02:06 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-06-07 16:02:06 +0200
commite2a54724247d42ebac65c0315fc4dbfaa2db5f80 (patch)
treeea5e8e7afc07f92cbf74904875ce69aa5f3cee91
parent810cc1c8281be8437ae0fd6257b2ea6190fe8d24 (diff)
parentaf39b570d41b634d12f9e19a0e799dbb18557312 (diff)
Merge branch 'release-filtering'
-rw-r--r--src/cli.rs20
-rw-r--r--src/commands/db.rs30
2 files changed, 17 insertions, 33 deletions
diff --git a/src/cli.rs b/src/cli.rs
index cdf35d3..a8b0cc1 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -390,23 +390,23 @@ pub fn cli<'a>() -> App<'a> {
.arg(arg_older_than_date("List only releases older than DATE"))
.arg(arg_newer_than_date("List only releases newer than DATE"))
- .arg(Arg::new("package_name_regex")
+ .arg(Arg::new("store")
.required(false)
.multiple(false)
- .long("pkg")
- .short('p')
+ .long("to")
.takes_value(true)
- .value_name("REGEX")
- .about("Limit search with package name matching REGEX")
+ .value_name("STORE")
+ .about("List only releases to STORE")
)
- .arg(Arg::new("package_version_constraint")
+
+ .arg(Arg::new("package")
.required(false)
.multiple(false)
- .long("version")
- .short('v')
+ .long("package")
+ .short('p')
.takes_value(true)
- .value_name("VERSION_CONSTRAINT")
- .about("Limit search for package in version VERSION")
+ .value_name("PKG")
+ .about("Only list releases for package PKG")
)
)
)
diff --git a/src/commands/db.rs b/src/commands/db.rs
index 08ed6c8..e984848 100644
--- a/src/commands/db.rs
+++ b/src/commands/db.rs
@@ -14,7 +14,6 @@ use std::io::Write;
use std::path::PathBuf;
use std::process::Command;
use std::str::FromStr;
-use std::convert::TryFrom;
use anyhow::Context;
use anyhow::Error;
@@ -34,11 +33,9 @@ use log::trace;
use crate::commands::util::get_date_filter;
use crate::config::Configuration;
-use crate::db::DbConnectionConfig;
use crate::db::models;
+use crate::db::DbConnectionConfig;
use crate::log::JobResult;
-use crate::package::PackageVersion;
-use crate::package::PackageVersionConstraint;
use crate::package::Script;
use crate::schema;
@@ -719,16 +716,13 @@ fn releases(conn_cfg: DbConnectionConfig<'_>, config: &Configuration, matches: &
query = query.filter(schema::releases::release_date.gt(date));
}
- let package_name_regex_filter = matches.value_of("package_name_regex")
- .map(crate::commands::util::mk_package_name_regex)
- .transpose()
- .context("Constructing package name regex")?;
+ if let Some(store) = matches.value_of("store") {
+ query = query.filter(schema::release_stores::dsl::store_name.eq(store));
+ }
- let package_version_filter = matches.value_of("package_version_constraint")
- .map(PackageVersionConstraint::try_from)
- .transpose()
- .context("Parsing package version constraint")
- .context("A valid package version constraint looks like this: '=1.0.0'")?;
+ if let Some(pkg) = matches.value_of("package") {
+ query = query.filter(schema::packages::dsl::name.eq(pkg));
+ }
let data = query
.select({
@@ -740,16 +734,6 @@ fn releases(conn_cfg: DbConnectionConfig<'_>, config: &Configuration, matches: &
})
.load::<(models::Artifact, models::Package, models::Release, models::ReleaseStore)>(&conn)?
.into_iter()
- .filter(|(_, package, _, _)| {
- package_name_regex_filter.as_ref()
- .map(|regex| regex.captures(&package.name).is_some())
- .unwrap_or(true)
- })
- .filter(|(_, package, _, _)| {
- package_version_filter.as_ref()
- .map(|verf| verf.matches(&PackageVersion::from(package.version.clone())))
- .unwrap_or(true)
- })
.filter_map(|(art, pack, rel, rstore)| {
let p = config.releases_directory().join(rstore.store_name).join(&art.path);