Skip to content

Commit

Permalink
Make rollup SHA easier to copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jun 25, 2023
1 parent b2e5ef8 commit abab51c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions site/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ pub async fn unroll_rollup(
previous_master: &str,
rollup_pr_number: u32,
) -> Result<(), String> {
let commit_link = |sha: &str| format!("https://github.com/rust-lang-ci/rust/commit/{sha}");

let format_commit = |s: &str, truncate: bool| {
let display = truncate.then(|| s.split_at(10).0).unwrap_or(s);
format!("[{display}](https://github.com/rust-lang-ci/rust/commit/{s})")
format!("[{display}]({})", commit_link(s))
};

// Sort rolled up commits by their PR number in ascending order, so that they have the
Expand All @@ -52,7 +54,11 @@ pub async fn unroll_rollup(
let commit = c
.sha
.as_deref()
.map(|s| format_commit(s, false))
.map(|s| {
// Format the SHA as a code block to make it easy to copy-paste verbatim
let link = commit_link(s);
format!("`{s}` ([link]({link}))")
})
.unwrap_or_else(|| {
let head = format_commit(&c.rolled_up_head, true);
format!("❌ conflicts merging '{head}' into previous master ❌")
Expand Down

0 comments on commit abab51c

Please sign in to comment.