Skip to content

Commit 8da5ed6

Browse files
committed
Do not hardcode default branch in rollup unroll webhook
1 parent f3f9ee3 commit 8da5ed6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

site/src/api.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,12 @@ pub mod github {
647647
pub head_commit: HeadCommit,
648648
pub before: String,
649649
pub commits: Vec<Commit>,
650+
pub repository: Repository,
651+
}
652+
653+
#[derive(Debug, Clone, Serialize, Deserialize)]
654+
pub struct Repository {
655+
pub default_branch: String,
650656
}
651657

652658
#[derive(Debug, Clone, Serialize, Deserialize)]

site/src/request_handlers/github.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub async fn handle_github(
2323

2424
async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<github::Response> {
2525
let gh_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
26-
if push.r#ref != "refs/heads/master" || push.sender.login != "bors" {
26+
if push.r#ref != format!("refs/heads/{}", push.repository.default_branch)
27+
|| push.sender.login != "bors"
28+
{
2729
return Ok(github::Response);
2830
}
2931
let rollup_pr_number = match rollup_pr_number(&gh_client, &push.head_commit.message).await? {

0 commit comments

Comments
 (0)