Use consistent change event order (#598)

Closes #591.
This commit is contained in:
Charlie Marsh 2023-12-08 23:12:40 -05:00 committed by GitHub
parent 714a64549b
commit 24d81912cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -304,7 +304,12 @@ pub(crate) async fn sync_requirements(
dist: AnyDist::from(distribution), dist: AnyDist::from(distribution),
kind: ChangeEventKind::Add, 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 { match event.kind {
ChangeEventKind::Add => { ChangeEventKind::Add => {
@ -331,12 +336,12 @@ pub(crate) async fn sync_requirements(
Ok(ExitStatus::Success) Ok(ExitStatus::Success)
} }
#[derive(Debug)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
enum ChangeEventKind { enum ChangeEventKind {
/// The package was added to the environment.
Add,
/// The package was removed from the environment. /// The package was removed from the environment.
Remove, Remove,
/// The package was added to the environment.
Add,
} }
#[derive(Debug)] #[derive(Debug)]