Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5daf090

Browse files
committed
Auto merge of rust-lang#16149 - lnicola:ignore-missing-prs, r=lnicola
internal: Don't fail changelog generation on missing PRs One year later 😅.
2 parents bd03f92 + 60281a6 commit 5daf090

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

xtask/src/release/changelog.rs

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,52 @@ pub(crate) fn get_changelog(
3030

3131
// we don't use an HTTPS client or JSON parser to keep the build times low
3232
let pr = pr_num.to_string();
33-
let pr_json =
34-
cmd!(sh, "curl -s -H {accept} -H {authorization} {pr_url}/{pr}").read()?;
33+
let cmd = &cmd!(sh, "curl --fail -s -H {accept} -H {authorization} {pr_url}/{pr}");
34+
let pr_json = match cmd.read() {
35+
Ok(pr_json) => pr_json,
36+
Err(e) => {
37+
// most likely a rust-lang/rust PR
38+
eprintln!("Cannot get info for #{pr}: {e}");
39+
continue;
40+
}
41+
};
42+
3543
let pr_title = cmd!(sh, "jq .title").stdin(&pr_json).read()?;
3644
let pr_title = unescape(&pr_title[1..pr_title.len() - 1]);
3745
let pr_comment = cmd!(sh, "jq .body").stdin(pr_json).read()?;
3846

39-
let comments_json =
40-
cmd!(sh, "curl -s -H {accept} -H {authorization} {pr_url}/{pr}/comments").read()?;
41-
let pr_comments = cmd!(sh, "jq .[].body").stdin(comments_json).read()?;
42-
43-
let l = iter::once(pr_comment.as_str())
44-
.chain(pr_comments.lines())
45-
.rev()
46-
.find_map(|it| {
47-
let it = unescape(&it[1..it.len() - 1]);
48-
it.lines().find_map(parse_changelog_line)
49-
})
50-
.into_iter()
51-
.next()
52-
.unwrap_or_else(|| parse_title_line(&pr_title));
53-
let s = match l.kind {
47+
let cmd =
48+
&cmd!(sh, "curl --fail -s -H {accept} -H {authorization} {pr_url}/{pr}/comments");
49+
let pr_info = match cmd.read() {
50+
Ok(comments_json) => {
51+
let pr_comments = cmd!(sh, "jq .[].body").stdin(comments_json).read()?;
52+
53+
iter::once(pr_comment.as_str())
54+
.chain(pr_comments.lines())
55+
.rev()
56+
.find_map(|it| {
57+
let it = unescape(&it[1..it.len() - 1]);
58+
it.lines().find_map(parse_changelog_line)
59+
})
60+
.into_iter()
61+
.next()
62+
}
63+
Err(e) => {
64+
eprintln!("Cannot get comments for #{pr}: {e}");
65+
None
66+
}
67+
};
68+
69+
let pr_info = pr_info.unwrap_or_else(|| parse_title_line(&pr_title));
70+
let s = match pr_info.kind {
5471
PrKind::Feature => &mut features,
5572
PrKind::Fix => &mut fixes,
5673
PrKind::Internal => &mut internal,
5774
PrKind::Other => &mut others,
5875
PrKind::Skip => continue,
5976
};
60-
writeln!(s, "* pr:{pr_num}[] {}", l.message.as_deref().unwrap_or(&pr_title)).unwrap();
77+
writeln!(s, "* pr:{pr_num}[] {}", pr_info.message.as_deref().unwrap_or(&pr_title))
78+
.unwrap();
6179
}
6280
}
6381

0 commit comments

Comments
 (0)