Skip to content

Commit 5e3b6ec

Browse files
committed
Sort crate dependencies before adding to index
Also ensure that the sorting of dependencies uses all fields.
1 parent 9d0f916 commit 5e3b6ec

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

cargo-registry-index/lib.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,26 @@ impl Ord for Dependency {
175175
// misinterpreted. With this manual `Ord` implementation we ensure that
176176
// `normal` dependencies are always first when multiple with the same
177177
// `name` exist.
178-
(&self.name, self.kind, &self.req).cmp(&(&other.name, other.kind, &other.req))
178+
(
179+
&self.name,
180+
self.kind,
181+
&self.req,
182+
self.optional,
183+
self.default_features,
184+
&self.target,
185+
&self.package,
186+
&self.features,
187+
)
188+
.cmp(&(
189+
&other.name,
190+
other.kind,
191+
&other.req,
192+
other.optional,
193+
other.default_features,
194+
&other.target,
195+
&other.package,
196+
&other.features,
197+
))
179198
}
180199
}
181200

src/controllers/krate/publish.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,9 @@ pub fn add_dependencies(
409409
})
410410
.collect::<Result<Vec<_>, _>>()?;
411411

412-
let (git_deps, new_dependencies): (Vec<_>, Vec<_>) =
412+
let (mut git_deps, new_dependencies): (Vec<_>, Vec<_>) =
413413
git_and_new_dependencies.into_iter().unzip();
414+
git_deps.sort();
414415

415416
insert_into(dependencies)
416417
.values(&new_dependencies)

0 commit comments

Comments
 (0)