From 24d81912cf75b0815bb6ce9fa2f3cda8decbb308 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 8 Dec 2023 23:12:40 -0500 Subject: [PATCH] Use consistent change event order (#598) Closes #591. --- crates/puffin-cli/src/commands/pip_sync.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/puffin-cli/src/commands/pip_sync.rs b/crates/puffin-cli/src/commands/pip_sync.rs index 92db27565..c2b7a0d00 100644 --- a/crates/puffin-cli/src/commands/pip_sync.rs +++ b/crates/puffin-cli/src/commands/pip_sync.rs @@ -304,7 +304,12 @@ pub(crate) async fn sync_requirements( dist: AnyDist::from(distribution), kind: ChangeEventKind::Add, })) - .sorted_unstable_by_key(|event| event.dist.name().clone()) + .sorted_unstable_by(|a, b| { + a.dist + .name() + .cmp(b.dist.name()) + .then_with(|| a.kind.cmp(&b.kind)) + }) { match event.kind { ChangeEventKind::Add => { @@ -331,12 +336,12 @@ pub(crate) async fn sync_requirements( Ok(ExitStatus::Success) } -#[derive(Debug)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] enum ChangeEventKind { - /// The package was added to the environment. - Add, /// The package was removed from the environment. Remove, + /// The package was added to the environment. + Add, } #[derive(Debug)]