Skip to content

Commit

Permalink
Merge pull request #1420 from nextstrain/fix/cli-tag-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov authored Feb 17, 2024
2 parents d7dda43 + 18ac993 commit 9010d85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/nextclade-cli/src/cli/nextclade_dataset_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn dataset_http_get(http: &HttpClient, name: impl AsRef<str>, tag: &Option<S
.filter(|dataset| -> bool {
// If a concrete version `tag` is specified, we skip 'enabled', 'compatibility' and 'latest' checks
if let Some(tag) = tag.as_ref() {
dataset.is_tag(tag)
dataset.has_tag(tag)
} else {
true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nextclade-cli/src/cli/nextclade_dataset_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn nextclade_dataset_list(
.flat_map(|collection| collection.datasets)
.filter(|dataset| -> bool {
if let Some(tag) = tag.as_ref() {
dataset.is_tag(tag)
dataset.has_tag(tag)
} else {
let is_compatible = include_incompatible || dataset.is_cli_compatible(this_package_version());
let is_not_deprecated = include_deprecated || !dataset.deprecated();
Expand Down
10 changes: 6 additions & 4 deletions packages/nextclade/src/io/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ impl Dataset {
.map_or(true, |compat| compat.is_cli_compatible(cli_version))
}

pub fn is_tag(&self, tag: impl AsRef<str>) -> bool {
pub fn has_tag(&self, tag: impl AsRef<str>) -> bool {
let tag = tag.as_ref();
self.version.tag == tag
|| (self.version.tag == "unreleased" && tag == "latest")
|| (self.version.tag == "latest" && tag == "unreleased")
self.versions.iter().any(|version| {
version.tag == tag
|| (version.tag == "unreleased" && tag == "latest")
|| (version.tag == "latest" && tag == "unreleased")
})
}
}

Expand Down

0 comments on commit 9010d85

Please sign in to comment.