Do not lookup pulls from default to default
@@ -315,6 +315,10 @@ impl GitHubRFDBranch {
/// Find any existing pull request coming from the branch for this RFD
pub async fn find_pull_requests(&self) -> Result<Vec<GitHubPullRequest>> {
+
+ // If this is an update is occurring on the master branch than we can skip the look up as
+ // we only want pull requests that are coming from an RFD branch
+ let prs = if self.branch != self.default_branch {
let pulls = self
.client
.pulls()
@@ -333,18 +337,20 @@ impl GitHubRFDBranch {
)
.await?;
- let mut matching_pulls = vec![];
-
- for pull in pulls.into_iter() {
- // Check if the pull request is for our branch.
+ pulls.into_iter().filter_map(|pull| {
let pull_branch = pull.head.ref_.trim_start_matches("refs/heads/");
if pull_branch == self.branch {
- matching_pulls.push(pull.into());
- }
+ Some(pull.into())
+ } else {
+ None
}
+ }).collect::<Vec<_>>()
+ } else {
+ vec![]
+ };
- Ok(matching_pulls)
+ Ok(prs)
}
pub async fn get_latest_commit_date(&self, rfd_number: &RFDNumber) -> Result<DateTime<Utc>> {
