Skip to content

Commit ac357d2

Browse files
authored
Merge pull request #78 from vohoanglong0107/fix-merge-try-build-url
fix: merge and try build url
2 parents a6945c2 + 66b2da0 commit ac357d2

File tree

3 files changed

+5
-25
lines changed

3 files changed

+5
-25
lines changed

src/github/api/client.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use tracing::log;
77
use crate::bors::event::PullRequestComment;
88
use crate::bors::{CheckSuite, CheckSuiteStatus, Comment, RepositoryClient};
99
use crate::config::{RepositoryConfig, CONFIG_FILE_PATH};
10+
use crate::github::api::base_github_html_url;
1011
use crate::github::api::operations::{merge_branches, set_branch_to_commit, MergeError};
11-
use crate::github::api::{base_github_html_url, base_github_url};
1212
use crate::github::{Branch, CommitSha, GithubRepoName, PullRequest, PullRequestNumber};
1313

1414
/// Provides access to a single app installation (repository) using the GitHub API.
@@ -85,8 +85,7 @@ impl RepositoryClient for GithubRepositoryClient {
8585
.client
8686
.get(
8787
format!(
88-
"{}/repos/{}/{}/branches/{name}",
89-
base_github_url(),
88+
"/repos/{}/{}/branches/{name}",
9089
self.repo_name.owner(),
9190
self.repo_name.name(),
9291
)
@@ -153,8 +152,7 @@ impl RepositoryClient for GithubRepositoryClient {
153152
.client
154153
.get(
155154
format!(
156-
"{}/repos/{}/{}/commits/{}/check-suites",
157-
base_github_url(),
155+
"/repos/{}/{}/commits/{}/check-suites",
158156
self.repo_name.owner(),
159157
self.repo_name.name(),
160158
sha.0

src/github/api/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ fn base_github_html_url() -> &'static str {
2525
"https://github.com"
2626
}
2727

28-
fn base_github_url() -> &'static str {
29-
"https://api.github.com"
30-
}
31-
3228
/// Provides access to managed GitHub repositories.
3329
pub struct GithubAppState {
3430
client: Octocrab,

src/github/api/operations.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::github::api::base_github_url;
21
use http::StatusCode;
32
use octocrab::params::repos::Reference;
43
use thiserror::Error;
@@ -42,19 +41,7 @@ pub async fn merge_branches(
4241
commit_message: &str,
4342
) -> Result<CommitSha, MergeError> {
4443
let client = repo.client();
45-
let merge_url = repo
46-
.repository
47-
.merges_url
48-
.as_ref()
49-
.map(|url| url.to_string())
50-
.unwrap_or_else(|| {
51-
format!(
52-
"{}/repos/{}/{}/merges",
53-
base_github_url(),
54-
repo.name().owner,
55-
repo.name().name
56-
)
57-
});
44+
let merge_url = format!("/repos/{}/{}/merges", repo.name().owner, repo.name().name);
5845

5946
let request = MergeRequest {
6047
base: base_ref,
@@ -150,8 +137,7 @@ async fn update_branch(
150137
sha: &CommitSha,
151138
) -> Result<(), BranchUpdateError> {
152139
let url = format!(
153-
"{}/repos/{}/{}/git/refs/{}",
154-
base_github_url(),
140+
"/repos/{}/{}/git/refs/{}",
155141
repo.name().owner(),
156142
repo.name().name(),
157143
Reference::Branch(branch_name.clone()).ref_url()

0 commit comments

Comments
 (0)