Skip to content

Commit 56a8eb5

Browse files
authored
Merge pull request #397 from JerryQ17/minimize-comment-v2
Add comment minimization logic and minimize try build started comments
2 parents df0e7cd + 63a1ecc commit 56a8eb5

22 files changed

+645
-79
lines changed

.sqlx/query-31a9c72676df4d3c7f13b7a0b92dcb7e473fa2086d7e4b84a9dd4aacac2fde28.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-6bb7558f15546f6b11396411a4b0461b25d20350e99cd55e8f0bc2bca2177134.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-94ce8ab6ef6cb76aa62aaf81c9f4b1751318faf2009b411b6cd616f47a82abf0.json

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.lock

Lines changed: 50 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ regex = "1"
7070
parking_lot = "0.12"
7171
thread_local = "1"
7272
sqlparser = { version = "0.58", features = ["visitor"] }
73+
graphql-parser = "0.4"
7374

7475
[profile.release]
7576
debug = 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DROP INDEX IF EXISTS comment_repo_pr_tag_idx;
2+
3+
DROP TABLE IF EXISTS comment;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE IF NOT EXISTS comment (
2+
id SERIAL PRIMARY KEY,
3+
repository TEXT NOT NULL,
4+
pr_number BIGINT NOT NULL,
5+
tag TEXT NOT NULL,
6+
node_id TEXT NOT NULL,
7+
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
8+
);
9+
10+
CREATE INDEX comment_repo_pr_tag_idx ON comment (repository, pr_number, tag);

src/bors/comment.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ pub enum CommentMetadata {
2424
TryBuildCompleted { merge_sha: String },
2525
}
2626

27+
/// A tag for a comment, used to identify the comment.
28+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
29+
pub enum CommentTag {
30+
TryBuildStarted,
31+
}
32+
2733
impl Comment {
2834
pub fn new(text: String) -> Self {
2935
Self {

src/bors/handlers/mod.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,23 @@ fn is_bors_observed_branch(branch: &str) -> bool {
574574
branch == TRY_BRANCH_NAME || branch == AUTO_BRANCH_NAME
575575
}
576576

577+
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
578+
pub enum BuildType {
579+
Try,
580+
Auto,
581+
}
582+
583+
/// Get the build type based on the branch where it happened.
584+
pub fn get_build_type(branch: &str) -> Option<BuildType> {
585+
if branch == TRY_BRANCH_NAME {
586+
Some(BuildType::Try)
587+
} else if branch == AUTO_BRANCH_NAME {
588+
Some(BuildType::Auto)
589+
} else {
590+
None
591+
}
592+
}
593+
577594
/// Deny permission for a request.
578595
async fn deny_request(
579596
repo: &RepositoryState,
@@ -593,7 +610,8 @@ async fn deny_request(
593610
author.username, permission_type
594611
)),
595612
)
596-
.await
613+
.await?;
614+
Ok(())
597615
}
598616

599617
/// Check if a user has specified permission or has been delegated.

src/bors/handlers/pr_events.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ async fn notify_of_edited_pr(
258258
PR will need to be re-approved."#,
259259
)),
260260
)
261-
.await
261+
.await?;
262+
Ok(())
262263
}
263264

264265
async fn notify_of_pushed_pr(
@@ -279,7 +280,8 @@ PR will need to be re-approved."#,
279280

280281
repo.client
281282
.post_comment(pr_number, Comment::new(comment))
282-
.await
283+
.await?;
284+
Ok(())
283285
}
284286

285287
#[cfg(test)]

0 commit comments

Comments
 (0)