Skip to content

Commit 8591515

Browse files
committed
Introduce a constant for GitHub API URL
1 parent dbf1dab commit 8591515

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

site/src/github.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use serde::Deserialize;
88

99
type BoxedError = Box<dyn std::error::Error + Send + Sync>;
1010

11+
pub const RUST_REPO_GITHUB_API_URL: &str = "https://api.github.com/repos/rust-lang/rust";
12+
1113
pub use comparison_summary::post_finished;
1214

1315
/// Enqueues try build artifacts and posts a message about them on the original rollup PR

site/src/github/comparison_summary.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::load::SiteCtxt;
66

77
use database::{ArtifactId, QueuedCommit};
88

9+
use crate::github::RUST_REPO_GITHUB_API_URL;
910
use std::collections::HashSet;
1011
use std::fmt::Write;
1112

@@ -66,10 +67,7 @@ pub async fn post_finished(ctxt: &SiteCtxt) {
6667
///
6768
/// `is_master_commit` is used to differentiate messages for try runs and post-merge runs.
6869
async fn post_comparison_comment(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit: bool) {
69-
let client = super::client::Client::from_ctxt(
70-
ctxt,
71-
"https://api.github.com/repos/rust-lang/rust".to_owned(),
72-
);
70+
let client = super::client::Client::from_ctxt(ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
7371
let pr = commit.pr;
7472
let body = match summarize_run(ctxt, commit, is_master_commit).await {
7573
Ok(message) => message,

site/src/request_handlers/github.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::api::{github, ServerResult};
2-
use crate::github::{client, enqueue_shas, parse_homu_comment, rollup_pr_number, unroll_rollup};
2+
use crate::github::{
3+
client, enqueue_shas, parse_homu_comment, rollup_pr_number, unroll_rollup,
4+
RUST_REPO_GITHUB_API_URL,
5+
};
36
use crate::load::SiteCtxt;
47

58
use std::sync::Arc;
@@ -29,10 +32,7 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
2932
&ctxt,
3033
"https://api.github.com/repos/rust-lang-ci/rust".to_owned(),
3134
);
32-
let main_repo_client = client::Client::from_ctxt(
33-
&ctxt,
34-
"https://api.github.com/repos/rust-lang/rust".to_owned(),
35-
);
35+
let main_repo_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
3636
if push.r#ref != "refs/heads/master" || push.sender.login != "bors" {
3737
return Ok(github::Response);
3838
}
@@ -70,10 +70,7 @@ async fn handle_issue(
7070
issue: github::Issue,
7171
comment: github::Comment,
7272
) -> ServerResult<github::Response> {
73-
let main_client = client::Client::from_ctxt(
74-
&ctxt,
75-
"https://api.github.com/repos/rust-lang/rust".to_owned(),
76-
);
73+
let main_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
7774
let ci_client = client::Client::from_ctxt(
7875
&ctxt,
7976
"https://api.github.com/repos/rust-lang-ci/rust".to_owned(),

0 commit comments

Comments
 (0)