From 2c4058b54a4e124bc29349ffe536e4e75e90dcc3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 18 Apr 2026 21:29:24 +0300 Subject: [PATCH] commands/update: use flexver for version sorting Signed-off-by: NotAShelf Change-Id: I4e1cd3247e74247cbde65391510bd3586a6a6964 --- src/cli/commands/update.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cli/commands/update.rs b/src/cli/commands/update.rs index 785219b..e532342 100644 --- a/src/cli/commands/update.rs +++ b/src/cli/commands/update.rs @@ -7,6 +7,7 @@ use crate::{ error::{MultiError, PakkerError}, model::{Config, LockFile, UpdateStrategy}, ui_utils::{prompt_select, prompt_typo_suggestion, prompt_yes_no}, + utils::FlexVer, }; pub async fn execute( @@ -141,6 +142,15 @@ pub async fn execute( && !updated_project.files.is_empty() && let Some(old_file) = lockfile.projects[idx].files.first() { + // Sort files by FlexVer if that strategy is set + if old_project.update_strategy == UpdateStrategy::FlexVer { + updated_project.files.sort_by(|a, b| { + // Use FlexVer for comparison - b.cmp(a) gives descending order + // (newest first) + FlexVer(&b.file_name).cmp(&FlexVer(&a.file_name)) + }); + } + // Clone data needed for comparisons to avoid borrow issues let new_file_id = updated_project.files.first().unwrap().id.clone(); let new_file_name =