MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / github_fetch_pr_runtime_info

Function github_fetch_pr_runtime_info

crates/opencode-cli/src/main.rs:4878–4913  ·  view source on GitHub ↗
(
    owner: &str,
    repo: &str,
    pr_number: u64,
    token: Option<&str>,
)

Source from the content-addressed store, hash-verified

4876}
4877
4878fn github_fetch_pr_runtime_info(
4879 owner: &str,
4880 repo: &str,
4881 pr_number: u64,
4882 token: Option<&str>,
4883) -> anyhow::Result<GithubPrRuntimeInfo> {
4884 let endpoint = format!("repos/{owner}/{repo}/pulls/{pr_number}");
4885 let value = gh_api_json("GET", &endpoint, None, token)?;
4886
4887 let head_ref = value
4888 .get("head")
4889 .and_then(|v| v.get("ref"))
4890 .and_then(|v| v.as_str())
4891 .ok_or_else(|| anyhow::anyhow!("PR {} is missing head.ref", pr_number))?
4892 .to_string();
4893 let head_repo_full_name = value
4894 .get("head")
4895 .and_then(|v| v.get("repo"))
4896 .and_then(|v| v.get("full_name"))
4897 .and_then(|v| v.as_str())
4898 .unwrap_or(&format!("{owner}/{repo}"))
4899 .to_string();
4900 let base_repo_full_name = value
4901 .get("base")
4902 .and_then(|v| v.get("repo"))
4903 .and_then(|v| v.get("full_name"))
4904 .and_then(|v| v.as_str())
4905 .unwrap_or(&format!("{owner}/{repo}"))
4906 .to_string();
4907
4908 Ok(GithubPrRuntimeInfo {
4909 head_ref,
4910 head_repo_full_name,
4911 base_repo_full_name,
4912 })
4913}
4914
4915fn github_generate_branch_name(prefix: &str, issue_number: Option<u64>) -> String {
4916 let stamp = chrono::Utc::now().format("%Y%m%d%H%M%S").to_string();

Callers 1

handle_github_commandFunction · 0.85

Calls 3

gh_api_jsonFunction · 0.85
getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected