Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/bors/handlers/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod tests {
async fn help_command(pool: sqlx::PgPool) {
run_test(pool, async |tester: &mut BorsTester| {
tester.post_comment("@bors help").await?;
insta::assert_snapshot!(tester.get_comment(()).await?, @r"
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r"
You can use the following commands:

## PR management
Expand Down
10 changes: 5 additions & 5 deletions src/bors/handlers/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod tests {
run_test(pool, async |tester: &mut BorsTester| {
tester.post_comment("@bors info").await?;
insta::assert_snapshot!(
tester.get_comment(()).await?,
tester.get_comment_text(()).await?,
@r"
## Status of PR `1`
- Not Approved
Expand All @@ -100,7 +100,7 @@ mod tests {

tester.post_comment("@bors info").await?;
insta::assert_snapshot!(
tester.get_comment(()).await?,
tester.get_comment_text(()).await?,
@r"
## Status of PR `1`
- Approved by: `default-user`
Expand All @@ -121,7 +121,7 @@ mod tests {

tester.post_comment("@bors info").await?;
insta::assert_snapshot!(
tester.get_comment(()).await?,
tester.get_comment_text(()).await?,
@r"
## Status of PR `1`
- Not Approved
Expand All @@ -142,7 +142,7 @@ mod tests {

tester.post_comment("@bors info").await?;
insta::assert_snapshot!(
tester.get_comment(()).await?,
tester.get_comment_text(()).await?,
@r"
## Status of PR `1`
- Not Approved
Expand Down Expand Up @@ -173,7 +173,7 @@ mod tests {

tester.post_comment("@bors info").await?;
insta::assert_snapshot!(
tester.get_comment(()).await?,
tester.get_comment_text(()).await?,
@r"
## Status of PR `1`
- Approved by: `default-user`
Expand Down
22 changes: 21 additions & 1 deletion src/bors/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::sync::Arc;

use super::mergeable_queue::MergeableQueueSender;
use crate::bors::command::{BorsCommand, CommandParseError};
use crate::bors::comment::CommentTag;
use crate::bors::event::{BorsGlobalEvent, BorsRepositoryEvent, PullRequestComment};
use crate::bors::handlers::help::command_help;
use crate::bors::handlers::info::command_info;
Expand All @@ -22,6 +23,7 @@ use crate::bors::handlers::workflow::{handle_workflow_completed, handle_workflow
use crate::bors::merge_queue::{AUTO_BRANCH_NAME, MergeQueueSender};
use crate::bors::{BorsContext, CommandPrefix, Comment, RepositoryState};
use crate::database::{DelegatedPermission, PullRequestModel};
use crate::github::api::client::HideCommentReason;
use crate::github::{GithubUser, LabelTrigger, PullRequest, PullRequestNumber};
use crate::permissions::PermissionType;
use crate::{CommandParser, PgDbClient, TeamApiClient, load_repositories};
Expand Down Expand Up @@ -657,6 +659,24 @@ async fn unapprove_pr(
handle_label_trigger(repo_state, pr.number, LabelTrigger::Unapproved).await
}

/// Hide all previous "Try build started" comments on the given PR.
async fn hide_try_build_started_comments(
repo: &RepositoryState,
db: &PgDbClient,
pr: &PullRequestModel,
) -> anyhow::Result<()> {
let outdated = db
.get_tagged_bot_comments(repo.repository(), pr.number, CommentTag::TryBuildStarted)
.await?;
for comment in outdated {
repo.client
.hide_comment(&comment.node_id, HideCommentReason::Outdated)
.await?;
db.delete_tagged_bot_comment(&comment).await?;
}
Ok(())
}

#[cfg(test)]
mod tests {
use crate::tests::{BorsTester, Comment, User, default_repo_name, run_test};
Expand Down Expand Up @@ -689,7 +709,7 @@ mod tests {
async fn unknown_command(pool: sqlx::PgPool) {
run_test(pool, async |tester: &mut BorsTester| {
tester.post_comment(Comment::from("@bors foo")).await?;
insta::assert_snapshot!(tester.get_comment(()).await?, @r#"Unknown command "foo". Run `@bors help` to see available commands."#);
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r#"Unknown command "foo". Run `@bors help` to see available commands."#);
Ok(())
})
.await;
Expand Down
2 changes: 1 addition & 1 deletion src/bors/handlers/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod tests {
async fn ping_command(pool: sqlx::PgPool) {
run_test(pool, async |tester: &mut BorsTester| {
tester.post_comment("@bors ping").await?;
assert_eq!(tester.get_comment(()).await?, "Pong 🏓!");
assert_eq!(tester.get_comment_text(()).await?, "Pong 🏓!");
Ok(())
})
.await;
Expand Down
16 changes: 8 additions & 8 deletions src/bors/handlers/pr_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,13 @@ mod tests {
.await?;

insta::assert_snapshot!(
tester.get_comment(()).await?,
tester.get_comment_text(()).await?,
@r"
:warning: The base branch changed to `beta`, and the
PR will need to be re-approved.
"
);
tester.get_pr(()).await.expect_unapproved();
tester.get_pr_copy(()).await.expect_unapproved();
Ok(())
})
.await;
Expand All @@ -337,7 +337,7 @@ mod tests {
tester.edit_pr((), |_| {}).await?;

tester
.get_pr(())
.get_pr_copy(())
.await
.expect_approved_by(&User::default_pr_author().name);
Ok(())
Expand Down Expand Up @@ -369,13 +369,13 @@ mod tests {
tester.push_to_pr(()).await?;

insta::assert_snapshot!(
tester.get_comment(()).await?,
tester.get_comment_text(()).await?,
@r"
:warning: A new commit `pr-1-commit-1` was pushed to the branch, the
PR will need to be re-approved.
"
);
tester.get_pr(()).await.expect_unapproved();
tester.get_pr_copy(()).await.expect_unapproved();
Ok(())
})
.await;
Expand Down Expand Up @@ -662,7 +662,7 @@ mod tests {
tester.wait_for_pr((), |pr| pr.auto_build.is_some()).await?;
tester.workflow_start(tester.auto_branch().await).await?;
tester.push_to_pr(()).await?;
insta::assert_snapshot!(tester.get_comment(()).await?, @r"
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r"
:warning: A new commit `pr-1-commit-1` was pushed to the branch, the
PR will need to be re-approved.

Expand Down Expand Up @@ -690,7 +690,7 @@ mod tests {

tester.workflow_start(tester.auto_branch().await).await?;
tester.push_to_pr(()).await?;
insta::assert_snapshot!(tester.get_comment(()).await?, @r"
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r"
:warning: A new commit `pr-1-commit-1` was pushed to the branch, the
PR will need to be re-approved.

Expand All @@ -709,7 +709,7 @@ mod tests {
tester.start_auto_build(()).await?;
tester.workflow_start(tester.auto_branch().await).await?;

let prev_commit = &tester.get_pr(()).await.get_gh_pr().head_sha;
let prev_commit = &tester.get_pr_copy(()).await.get_gh_pr().head_sha;
tester.push_to_pr(()).await?;
tester.expect_comments((), 1).await;
tester
Expand Down
10 changes: 5 additions & 5 deletions src/bors/handlers/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ timeout = 3600
tester.cancel_timed_out_builds().await;
})
.await;
insta::assert_snapshot!(tester.get_comment(()).await?, @":boom: Test timed out after `3600`s");
insta::assert_snapshot!(tester.get_comment_text(()).await?, @":boom: Test timed out after `3600`s");
assert_eq!(
tester
.db()
Expand Down Expand Up @@ -315,7 +315,7 @@ timeout = 3600

tester
.expect_check_run(
&tester.get_pr(()).await.get_gh_pr().head_sha,
&tester.get_pr_copy(()).await.get_gh_pr().head_sha,
TRY_BUILD_CHECK_RUN_NAME,
"Bors try build",
CheckRunStatus::Completed,
Expand Down Expand Up @@ -381,7 +381,7 @@ timeout = 3600
.await?;
tester.refresh_prs().await;
tester
.get_pr(pr.number)
.get_pr_copy(pr.number)
.await
.expect_status(PullRequestStatus::Open);
Ok(())
Expand All @@ -401,7 +401,7 @@ timeout = 3600
.await?;
tester.refresh_prs().await;
tester
.get_pr(pr.number)
.get_pr_copy(pr.number)
.await
.expect_status(PullRequestStatus::Closed);
Ok(())
Expand All @@ -421,7 +421,7 @@ timeout = 3600

tester.refresh_prs().await;
tester
.get_pr(pr.number)
.get_pr_copy(pr.number)
.await
.expect_status(PullRequestStatus::Draft);
Ok(())
Expand Down
Loading
Loading