Skip to content

Commit 9ace44c

Browse files
authored
Merge pull request #230 from Sakib25800/feat/track-base
Track base branch
2 parents bc6c7db + d07200c commit 9ace44c

21 files changed

+887
-97
lines changed

.sqlx/query-0f95314b0c0debde970dd27f33ced6c3463e9e31131dbb39b4514f041e95939b.json

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

.sqlx/query-171a79e16e89f8ad9d2fd897455d87ad5a7ca3eba6f59eabe66a008d1ce864c4.json renamed to .sqlx/query-80d2c1b695162729675c566946a145a78feed990078fbd50a83ada38a225597d.json

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

.sqlx/query-8f940c2da5f3cf3f41b39e7c78d9e254da0d1fa8de59af33ade50cb2ac34c917.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

.sqlx/query-96805d5e3b9f430d100135ba4dc9face8cca0684d03343d5466deffbdb4fbdac.json

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

.sqlx/query-181b548e2a8a50573b30c7d7c703ca6b49c8278bddd103dcb2c84e0b3c95cc3d.json renamed to .sqlx/query-d6aed6aa0d89754e5dbe1fdafd3fbccb522960b2a1b81bba5fa197e9da710126.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add down migration script here
2+
ALTER TABLE pull_request DROP COLUMN base_branch;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add up migration script here
2+
ALTER TABLE pull_request ADD COLUMN base_branch TEXT NOT NULL;

src/bors/event.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub enum BorsRepositoryEvent {
1111
PullRequestCommitPushed(PullRequestPushed),
1212
/// When the pull request is edited by its author
1313
PullRequestEdited(PullRequestEdited),
14+
/// When a pull request is opened.
15+
PullRequestOpened(PullRequestOpened),
1416
/// A workflow run on Github Actions or a check run from external CI system has been started.
1517
WorkflowStarted(WorkflowStarted),
1618
/// A workflow run on Github Actions or a check run from external CI system has been completed.
@@ -26,6 +28,7 @@ impl BorsRepositoryEvent {
2628
BorsRepositoryEvent::Comment(comment) => &comment.repository,
2729
BorsRepositoryEvent::PullRequestCommitPushed(payload) => &payload.repository,
2830
BorsRepositoryEvent::PullRequestEdited(payload) => &payload.repository,
31+
BorsRepositoryEvent::PullRequestOpened(payload) => &payload.repository,
2932
BorsRepositoryEvent::WorkflowStarted(workflow) => &workflow.repository,
3033
BorsRepositoryEvent::WorkflowCompleted(workflow) => &workflow.repository,
3134
BorsRepositoryEvent::CheckSuiteCompleted(payload) => &payload.repository,
@@ -72,6 +75,12 @@ pub struct PullRequestEdited {
7275
pub from_base_sha: Option<CommitSha>,
7376
}
7477

78+
#[derive(Debug)]
79+
pub struct PullRequestOpened {
80+
pub repository: GithubRepoName,
81+
pub pull_request: PullRequest,
82+
}
83+
7584
#[derive(Debug)]
7685
pub struct WorkflowStarted {
7786
pub repository: GithubRepoName,

src/bors/handlers/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(super) async fn command_info(
1212
) -> anyhow::Result<()> {
1313
// Geting PR info from database
1414
let pr_model = db
15-
.get_or_create_pull_request(repo.client.repository(), pr.number)
15+
.get_or_create_pull_request(repo.client.repository(), pr.number, &pr.base.name)
1616
.await?;
1717

1818
// Building the info message

src/bors/handlers/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ use crate::permissions::PermissionType;
1919
use crate::{load_repositories, PgDbClient, TeamApiClient};
2020
use anyhow::Context;
2121
use octocrab::Octocrab;
22-
use pr_events::{handle_pull_request_edited, handle_push_to_pull_request};
22+
use pr_events::{
23+
handle_pull_request_edited, handle_pull_request_opened, handle_push_to_pull_request,
24+
};
2325
use review::{command_delegate, command_set_priority, command_set_rollup, command_undelegate};
2426
use tracing::Instrument;
2527

@@ -136,6 +138,14 @@ pub async fn handle_bors_repository_event(
136138
.instrument(span.clone())
137139
.await?;
138140
}
141+
BorsRepositoryEvent::PullRequestOpened(payload) => {
142+
let span =
143+
tracing::info_span!("Pull request opened", repo = payload.repository.to_string());
144+
145+
handle_pull_request_opened(repo, db, payload)
146+
.instrument(span.clone())
147+
.await?;
148+
}
139149
}
140150
Ok(())
141151
}
@@ -425,7 +435,7 @@ async fn has_permission(
425435
}
426436

427437
let pr_model = db
428-
.get_or_create_pull_request(repo_state.repository(), pr.number)
438+
.get_or_create_pull_request(repo_state.repository(), pr.number, &pr.base.name)
429439
.await?;
430440
let is_delegated = pr_model.delegated && author.id == pr.author.id;
431441

0 commit comments

Comments
 (0)