Skip to content

Commit a113a3d

Browse files
committed
docs: for github module
1 parent e23ea9b commit a113a3d

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/github.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
//! GitHub API
2-
#![allow(
3-
clippy::missing_docs_in_private_items,
4-
reason = "GitHub API is self-explanatory"
5-
)]
62
73
use std::process;
84

@@ -16,21 +12,27 @@ use crate::{
1612
};
1713
use anyhow::{Result, anyhow};
1814

19-
/// Data returned by GitHub's API
15+
/// Data returned by GitHub's API for the pull request endpoint per repo
2016
#[derive(Serialize, Deserialize, Debug)]
21-
pub struct GitHubResponse {
17+
pub struct PrData {
18+
/// Data about the head repository
2219
pub head: Head,
20+
/// Title of the pull request
2321
pub title: String,
22+
/// Url to the pull request
2423
pub html_url: String,
2524
}
2625

26+
/// Head repository (returned by github api)
2727
#[derive(Serialize, Deserialize, Debug)]
2828
pub struct Head {
29+
/// Repo for the PR
2930
pub repo: Repo,
31+
/// Name of the branch of the PR
3032
pub r#ref: BranchName,
3133
}
3234

33-
impl GitHubResponse {
35+
impl PrData {
3436
/// The endpoint which returns the structure [`GitHubResponse`]
3537
fn endpoint(repo: &str, pull_request: PrNumber) -> String {
3638
format!("https://api.github.com/repos/{repo}/pulls/{pull_request}")
@@ -51,21 +53,30 @@ impl Repo {
5153
}
5254
}
5355

56+
/// Branch
5457
#[derive(Debug)]
5558
pub struct Branch {
59+
/// Name of the branch as it is on the remote
5660
pub upstream_branch_name: BranchName,
61+
/// Name of the branch when we want to clone it locally
5762
pub local_branch_name: BranchName,
5863
}
5964

65+
/// Remote
6066
#[derive(Debug)]
6167
pub struct Remote {
68+
/// Link to the remote repository
6269
pub repository_url: String,
70+
/// Name of the remote as it exists locally
6371
pub local_remote_alias: String,
6472
}
6573

74+
/// Associates a remote with a branch
6675
#[derive(Debug)]
6776
pub struct RemoteBranch {
77+
/// Remote
6878
pub remote: Remote,
79+
/// Branch
6980
pub branch: Branch,
7081
}
7182

@@ -140,10 +151,10 @@ pub async fn fetch_pull_request(
140151
custom_branch_name: Option<BranchName>,
141152
commit_hash: Option<&CommitId>,
142153
use_gh_cli: bool,
143-
) -> Result<(GitHubResponse, RemoteBranch)> {
144-
let url = GitHubResponse::endpoint(repo, pull_request);
154+
) -> Result<(PrData, RemoteBranch)> {
155+
let url = PrData::endpoint(repo, pull_request);
145156

146-
let response = get_gh_api::<GitHubResponse>(&url, use_gh_cli)
157+
let response = get_gh_api::<PrData>(&url, use_gh_cli)
147158
.await
148159
.map_err(|err| anyhow!("failed to fetch pull request #{pull_request}\n{err}\n"))??;
149160

0 commit comments

Comments
 (0)