Skip to content

Commit

Permalink
rn fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
prsabahrami committed Jan 27, 2025
1 parent 07e13e3 commit 6b441f9
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions tests/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,12 @@ impl FromStr for Spec {
fn from_str(s: &str) -> Result<Self, Self::Err> {

Check warning on line 138 in tests/solver.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/resolvo/resolvo/tests/solver.rs
let split = s.split(';').collect::<Vec<_>>(); // c 1; if b 1..2

if split.len() == 1 {
// c 1
if split.len() == 1 { // c 1
let split = s.split(' ').collect::<Vec<_>>();
let name = split
.first()
.expect("spec does not have a name")
.to_string();
let name = split.first().expect("spec does not have a name").to_string();
let versions = version_range(split.get(1));
return Ok(Spec::new(name, versions, None));
}
}

let binding = split.get(1).unwrap().replace("if", "");
let condition = Spec::parse_union(&binding).next().unwrap().unwrap();
Expand All @@ -171,11 +167,7 @@ impl FromStr for Spec {
}

Check warning on line 167 in tests/solver.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/resolvo/resolvo/tests/solver.rs
}

Ok(Spec::new(
spec.name,
spec.versions,
Some(Box::new(condition)),
))
Ok(Spec::new(spec.name, spec.versions, Some(Box::new(condition))))
}
}

Expand Down Expand Up @@ -521,7 +513,7 @@ impl DependencyProvider for BundleBoxProvider {
let requirement = if remaining_req_specs.len() == 0 {

Check warning on line 513 in tests/solver.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/resolvo/resolvo/tests/solver.rs
if let Some(condition) = &first.condition {
ConditionalRequirement::new(
Some(self.intern_version_set(condition)),
Some(self.intern_version_set(condition)),
first_version_set.into(),
)
} else {
Expand All @@ -530,27 +522,26 @@ impl DependencyProvider for BundleBoxProvider {
} else {

Check warning on line 522 in tests/solver.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/resolvo/resolvo/tests/solver.rs
// Check if all specs have the same condition
let common_condition = first.condition.as_ref().map(|c| self.intern_version_set(c));

// Collect version sets for union
let mut version_sets = vec![first_version_set];
for spec in remaining_req_specs {
// Verify condition matches

Check warning on line 529 in tests/solver.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/resolvo/resolvo/tests/solver.rs
if spec.condition.as_ref().map(|c| self.intern_version_set(c))
!= common_condition
{
if spec.condition.as_ref().map(|c| self.intern_version_set(c)) != common_condition {
panic!("All specs in a union must have the same condition");
}

version_sets.push(self.pool.intern_version_set(
self.pool.intern_package_name(&spec.name),
spec.versions.clone(),
spec.versions.clone()
));
}

// Create union and wrap in conditional if needed

Check warning on line 540 in tests/solver.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/resolvo/resolvo/tests/solver.rs
let union = self
.pool
.intern_version_set_union(version_sets[0], version_sets.into_iter().skip(1));
let union = self.pool.intern_version_set_union(
version_sets[0],
version_sets.into_iter().skip(1)
);

if let Some(condition) = common_condition {
ConditionalRequirement::new(Some(condition), union.into())
Expand Down

0 comments on commit 6b441f9

Please sign in to comment.