aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package/version/version_selector.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
commita1c7e6908a26e10f6e1f23a51721664b5e2d838d (patch)
treec575c76f1b43359ed74913da4c6a2636643f1ba0 /crates/shirabe/src/package/version/version_selector.rs
parent7f606f36fef0c0467c3c0db3d0da33af486dae8a (diff)
downloadphp-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.gz
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.zst
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.zip
chore(style): cargo fmt
Diffstat (limited to 'crates/shirabe/src/package/version/version_selector.rs')
-rw-r--r--crates/shirabe/src/package/version/version_selector.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/crates/shirabe/src/package/version/version_selector.rs b/crates/shirabe/src/package/version/version_selector.rs
index 85ce71d..f665320 100644
--- a/crates/shirabe/src/package/version/version_selector.rs
+++ b/crates/shirabe/src/package/version/version_selector.rs
@@ -5,7 +5,7 @@ use std::any::Any;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::preg::Preg;
use shirabe_php_shim::{
- strtolower, version_compare, PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION,
+ PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, strtolower, version_compare,
};
use shirabe_semver::constraint::constraint::Constraint;
use shirabe_semver::constraint::constraint_interface::ConstraintInterface;
@@ -20,9 +20,9 @@ use crate::package::base_package::BasePackage;
use crate::package::dumper::array_dumper::ArrayDumper;
use crate::package::loader::array_loader::ArrayLoader;
use crate::package::package_interface::PackageInterface;
+use crate::package::version::version_parser::VersionParser;
use crate::repository::platform_repository::PlatformRepository;
use crate::repository::repository_set::RepositorySet;
-use crate::package::version::version_parser::VersionParser;
#[derive(Debug)]
pub struct VersionSelector {
@@ -140,7 +140,8 @@ impl VersionSelector {
if link.get_constraint().matches(provided_constraint.as_ref()) {
continue 'reqs;
}
- let list_filter_opt = (platform_requirement_filter.as_ref() as &dyn Any)
+ let list_filter_opt = (platform_requirement_filter.as_ref()
+ as &dyn Any)
.downcast_ref::<IgnoreListPlatformRequirementFilter>();
if let Some(list_filter) = list_filter_opt {
if list_filter.is_upper_bound_ignored(name) {
@@ -168,8 +169,7 @@ impl VersionSelector {
_ => true,
};
if should_warn {
- let warn_key =
- format!("{}/{}", pkg.get_name(), link.get_target());
+ let warn_key = format!("{}/{}", pkg.get_name(), link.get_target());
let is_first_warning = !already_warned_names.contains_key(&warn_key);
already_warned_names.insert(warn_key, true);
let latest = if is_latest_version {
@@ -222,15 +222,16 @@ impl VersionSelector {
Some(p) => p,
};
- let package = if let Some(alias) = (package.as_ref() as &dyn Any).downcast_ref::<AliasPackage>() {
- if alias.get_version() == VersionParser::DEFAULT_BRANCH_ALIAS {
- alias.get_alias_of()
+ let package =
+ if let Some(alias) = (package.as_ref() as &dyn Any).downcast_ref::<AliasPackage>() {
+ if alias.get_version() == VersionParser::DEFAULT_BRANCH_ALIAS {
+ alias.get_alias_of()
+ } else {
+ package
+ }
} else {
package
- }
- } else {
- package
- };
+ };
Ok(Some(package))
}
@@ -288,7 +289,10 @@ impl VersionSelector {
if semantic_version_parts.len() == 4
&& Preg::is_match(r"{^\d+\D?}", semantic_version_parts[3]).unwrap_or(false)
{
- let mut parts: Vec<String> = semantic_version_parts.iter().map(|s| s.to_string()).collect();
+ let mut parts: Vec<String> = semantic_version_parts
+ .iter()
+ .map(|s| s.to_string())
+ .collect();
let version = if parts[0] == "0" {
parts.truncate(3);
parts.join(".")