Skip to content

Commit 9f301d9

Browse files
committed
Sort unrolled builds in rollup comment by PR number
This makes sure that they will be ordered in the same way as in the rollup PR description.
1 parent 807f108 commit 9f301d9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

site/src/github.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ pub async fn unroll_rollup(
3333
let display = truncate.then(|| s.split_at(10).0).unwrap_or(s);
3434
format!("[{display}](https://github.com/rust-lang-ci/rust/commit/{s})")
3535
};
36-
let mapping = enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master)
37-
.await?
36+
37+
// Sort rolled up commits by their PR number in ascending order, so that they have the
38+
// same ordering as in the rollup PR description.
39+
let mut unrolled_builds: Vec<UnrolledCommit> =
40+
enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master).await?;
41+
unrolled_builds.sort_unstable_by(|a, b| {
42+
a.original_pr_number
43+
.parse::<u64>()
44+
.and_then(|a| b.original_pr_number.parse::<u64>().map(|b| a.cmp(&b)))
45+
.unwrap_or_else(|_| a.original_pr_number.cmp(b.original_pr_number))
46+
});
47+
48+
let mapping = unrolled_builds
3849
.into_iter()
3950
.fold(String::new(), |mut string, c| {
4051
use std::fmt::Write;

0 commit comments

Comments
 (0)