diff --git a/src/handlers/milestone_prs.rs b/src/handlers/milestone_prs.rs index bf363dae..a2b68cdf 100644 --- a/src/handlers/milestone_prs.rs +++ b/src/handlers/milestone_prs.rs @@ -145,24 +145,34 @@ async fn milestone_cargo( // , // but it is a little awkward to use, only works on the default branch, // and this is a bit simpler/faster. However, it is sensitive to the - // specific messages generated by bors, and won't catch things merged - // without bors. - let merge_re = Regex::new("(?:Auto merge of|Merge pull request) #([0-9]+)").unwrap(); - - let pr_nums = commits.iter().filter_map(|commit| { - log::info!( - "getting PR number for cargo commit {} (len={})", - commit.sha, - commit.commit.message.len() - ); - merge_re.captures(&commit.commit.message).map(|cap| { - cap.get(1) - .unwrap() - .as_str() - .parse::() - .expect("digits only") - }) - }); + // specific messages generated by bors or GitHub merge queue, and won't + // catch things merged beyond them. + let merge_re = + Regex::new(r"(?:Auto merge of|Merge pull request) #([0-9]+)|\(#([0-9]+)\)$").unwrap(); + + let pr_nums = commits + .iter() + .filter(|commit| + // Assumptions: + // * A merge commit always has two parent commits. + // * Cargo's PR never got merged as fast-forward / rebase / squash merge. + commit.parents.len() == 2) + .filter_map(|commit| { + log::info!( + "getting PR number for cargo commit {} (len={})", + commit.sha, + commit.commit.message.len() + ); + + merge_re.captures(&commit.commit.message).map(|cap| { + cap.get(1) + .or_else(|| cap.get(2)) + .unwrap() + .as_str() + .parse::() + .expect("digits only") + }) + }); let milestone = cargo_repo .get_or_create_milestone(gh, release_version, "closed") .await?;