Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bors/build_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async fn maybe_timeout_build(
BuildKind::Auto => LabelTrigger::AutoBuildFailed,
};
let gh_pr = repo.client.get_pull_request(pr.number).await?;
handle_label_trigger(repo, &gh_pr, trigger).await?;
handle_label_trigger(repo, &gh_pr.into(), trigger).await?;

if let Err(error) = repo
.client
Expand Down Expand Up @@ -348,7 +348,7 @@ async fn maybe_complete_build(
.await?;
if let Some(trigger) = trigger {
let pr = repo.client.get_pull_request(pr_num).await?;
handle_label_trigger(repo, &pr, trigger).await?;
handle_label_trigger(repo, &pr.into(), trigger).await?;
}

if let Some(check_run_id) = build.check_run_id {
Expand Down
7 changes: 6 additions & 1 deletion src/bors/handlers/autobuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ pub(super) async fn command_retry(
merge_queue_tx.notify().await?;

// Retrying is essentially like a reapproval
handle_label_trigger(&repo_state, pr.github, LabelTrigger::Approved).await?;
handle_label_trigger(
&repo_state,
&pr.github.clone().into(),
LabelTrigger::Approved,
)
.await?;
} else {
let pending_auto_build = pr_model
.auto_build
Expand Down
6 changes: 3 additions & 3 deletions src/bors/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::bors::{
TRY_BRANCH_NAME,
};
use crate::database::{DelegatedPermission, PullRequestModel};
use crate::github::{CommitSha, GithubUser, LabelTrigger, PullRequest, PullRequestNumber};
use crate::github::{CommitSha, GithubUser, LabelTrigger, PullRequest, PullRequestNumber, PullRequestSummary};
use crate::permissions::PermissionType;
use crate::{PgDbClient, TeamApiClient, load_repositories};
use anyhow::Context;
Expand Down Expand Up @@ -751,7 +751,7 @@ pub async fn unapprove_pr(
repo_state: &RepositoryState,
db: &PgDbClient,
pr_db: &PullRequestModel,
pr_gh: &PullRequest,
pr_gh: &PullRequestSummary,
) -> anyhow::Result<()> {
db.unapprove(pr_db).await?;
handle_label_trigger(repo_state, pr_gh, LabelTrigger::Unapproved).await?;
Expand Down Expand Up @@ -817,7 +817,7 @@ pub async fn invalidate_pr(
// Step 1: unapprove the pull request if it was approved
// This happens everytime the PR is invalidated, if it was approved before
let pr_unapproved = if pr_db.is_approved() {
unapprove_pr(repo_state, db, pr_db, pr_gh).await?;
unapprove_pr(repo_state, db, pr_db, &pr_gh.clone().into()).await?;
true
} else {
false
Expand Down
32 changes: 12 additions & 20 deletions src/bors/handlers/pr_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::bors::{AUTO_BRANCH_NAME, BorsContext, hide_tagged_comments};
use crate::bors::{PullRequestStatus, RepositoryState};
use crate::database::{PullRequestModel, UpsertPullRequestParams};
use crate::github::CommitSha;
use crate::utils::text::pluralize;
use std::sync::Arc;

pub(super) async fn handle_pull_request_edited(
Expand Down Expand Up @@ -243,29 +242,22 @@ pub(super) async fn handle_push_to_branch(
mergeability_queue: &MergeabilityQueueSender,
payload: PushToBranch,
) -> anyhow::Result<()> {
let affected_prs = db
.set_stale_mergeability_status_by_base_branch(repo_state.repository(), &payload.branch)
db.set_stale_mergeability_status_by_base_branch(repo_state.repository(), &payload.branch)
.await?;

if !affected_prs.is_empty() {
tracing::info!(
"Adding {} {} to the mergeability queue due to a new commit pushed to base branch `{}`",
affected_prs.len(),
pluralize("PR", affected_prs.len()),
payload.branch
);
tracing::info!(
"Adding a batch to the mergeability queue due to a new commit pushed to base branch `{}`",
payload.branch
);

// Try to find an auto build that matches this SHA
let merged_pr = find_pr_by_merged_commit(&repo_state, &db, CommitSha(payload.sha))
.await
.ok()
.flatten()
.map(|pr| pr.number);
// Try to find an auto build that matches this SHA
let merged_pr = find_pr_by_merged_commit(&repo_state, &db, CommitSha(payload.sha))
.await
.ok()
.flatten()
.map(|pr| pr.number);

for pr in affected_prs {
mergeability_queue.enqueue_pr(&pr, merged_pr);
}
}
mergeability_queue.enqueue_batch(repo_state.repository(), &payload.branch, merged_pr);

Ok(())
}
Expand Down
7 changes: 6 additions & 1 deletion src/bors/handlers/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ pub(super) async fn command_approve(
)
.await?;

handle_label_trigger(&repo_state, pr.github, LabelTrigger::Approved).await
handle_label_trigger(
&repo_state,
&pr.github.clone().into(),
LabelTrigger::Approved,
)
.await
}

/// Normalize approvers (given after @bors r=) by removing leading @, possibly from multiple
Expand Down
4 changes: 2 additions & 2 deletions src/bors/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::collections::HashSet;
use tracing::log;

use crate::bors::RepositoryState;
use crate::github::{LabelModification, LabelTrigger, PullRequest};
use crate::github::{LabelModification, LabelTrigger, PullRequestSummary};

/// If there are any label modifications that should be performed on the given PR when `trigger`
/// happens, this function will perform them.
pub async fn handle_label_trigger(
repo: &RepositoryState,
pr: &PullRequest,
pr: &PullRequestSummary,
trigger: LabelTrigger,
) -> anyhow::Result<()> {
let mut add: Vec<String> = Vec::new();
Expand Down
6 changes: 3 additions & 3 deletions src/bors/merge_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ async fn handle_start_auto_build(
update_pr_with_known_mergeability(
repo,
&ctx.db,
&gh_pr,
&gh_pr.into(),
pr,
mergeability_sender.get_conflict_source(pr),
)
Expand Down Expand Up @@ -405,7 +405,7 @@ async fn handle_start_auto_build(
update_pr_with_known_mergeability(
repo,
&ctx.db,
&gh_pr,
&gh_pr.into(),
pr,
mergeability_sender.get_conflict_source(pr),
)
Expand Down Expand Up @@ -466,7 +466,7 @@ Actual head SHA: {actual_sha}"#,

// Note: we don't use invalidate_pr here, because we know that the PR is a rollup,
// to have more control over the message.
unapprove_pr(repo, &ctx.db, pr, &gh_pr).await?;
unapprove_pr(repo, &ctx.db, pr, &gh_pr.clone().into()).await?;

mismatches.sort_by_key(|mismatch| mismatch.member);

Expand Down
Loading
Loading